|
Thanks for the insight. Now I must look at the differences/advantages of ADO.net v ADO.
Regards,
John John
|
|
|
|
|
ADO.net (DataAdapters and suchlike) is quite nice. And you also have the potential of an entity management system like Entity Framework or NHibernate. However, that's not likely to be practical on a large existing database, and once you've written the queries, things aren't that different.
If you were starting a new project from scratch I'd advise using C# but the gains are not going to pay back the massive cost of moving an existing system, particularly if your team would have to start learning from the ground up.
|
|
|
|
|
Thank you for your comment and some topics to investigate regarding ADO.net.
Yes, the learning curve and porting our existing system is an important consider for staying with C++.
- John John
|
|
|
|
|
john john mackey wrote: Can I get some feedback/opinions on the pros and cons of each - C++ and C# ?
That isn't logical.
You can't make a technological decision wildly. It needs to be based on your business needs.
Some possible considerations.
- You have a team of 10 C++ senior developers with no C# experience. And the application meets all of the current business needs. And the C++ developers want do continue using C++. So the ONLY decision is to keep using C++.
- You have a team of 10 C++ developers with varying experience levels in C++ and C#. The application meets all of the current business needs. But 5 developers with the most business knowledge are threatening to quit unless you start using C#. So the only decision is to use C#.
- Your largest customer produces 80% of your business income and insists that you use either C++ or C#. So that is what you use.
- Your largest customer produces 80% of your business income and insists that you implement a feature that can only be implemented in either C++ or C#. So that is what you use. (This is probably a stretch scenario.)
- Your business plan calls for you selling the company to Microsoft. Then use C#.
- Your business plan calls for you selling the company to Oracle. Then use C++. Or Java. Regardless re-write to use Oracle instead of SQL Server.
- Your application is 1000% slower than it should be. You have a design/architecture/requirements problem. It has NOTHING to do with language choice.
- etc, etc, etc...
|
|
|
|
|
I have a C#.net 2008 desktop application that I need to modify for the first time. This application has a tablelayout panel that I would like to know how to modify. On this tablelayout panel I want to add a textbox and a label control between two existing label and textbox controls that are already on the table layout panel. Since I am new to working with desktop applications, can you tell me and/or show me to a reference on how to modify a existing table layout panenl control?
|
|
|
|
|
Just drag and drop them into the desired location on the designer.
If they are added dynamically via code instead of using the designer, use yourPanel.Controls.Add to put them where they belong.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
A good way to get familiar quickly with how Controls are added, moved, etc. in a container like TableLayoutPanel is to start a new project (we're assuming WinForms here).
Put a TableLayoutPanel on the Form, set up some rows and columns, drag and drop a Label into one cell, and a TextBox into the next cell on the same row you put the Label.
Then open the Designer.cs file, and observe how those controls are added to specific cells in the TableLayoutPanel:
this.tableLayoutPanel1.Controls.Add(this.textBox1, 2, 1);
this.tableLayoutPanel1.Controls.Add(this.label1, 1, 1); An interesting thing is that if you inspect the Controls you've added, you'll see Row and Column properties available in the Property Grid browser, but the Controls themselves are not "extended," i.e., do not expose these properties in code you write.
So how do you move the TextBox to the next cell right of its current location. Like this:
private void MoveTextBox_Click(object sender, EventArgs e)
{
var tbPosition = tableLayoutPanel1.GetPositionFromControl(textBox1);
tbPosition.Column++;
tableLayoutPanel1.SetCellPosition(textBox2, tbPosition);
} This crude example is just to show the basic mechanism; for production code you'd want to write, I think, a generalized procedure with parameters that would include the Control to be moved, and either a fixed location to be moved to, or relative vertical and/or horizontal offsets, and you'd want to error check that you were not trying to move something outside the TableLayoutPanel cell-bounds (which does not throw an error if you do, by the way: the control just stays in the same place).
Another strategy would be to use the 'Remove method of the TableLayOut.Controls collection, and then insert them back in where you wished.
tableLayoutPanel1.Controls.Remove(textBox1);
tableLayoutPanel1.Controls.Add(textBox1,0,0); If you are adding new Controls at run-time, you are, of course, going to need to keep references to those Controls if you wish to re-use them after removing them from your container.
good luck, Bill
"Anyone who shows me my 'blind spots' gives me the gift of sight." ... a thought from the shallows of the deeply shallow mind of ... Bill
modified 30-Nov-11 20:36pm.
|
|
|
|
|
According to the article here:
http://msdn.microsoft.com/en-us/library/t9883dzc.aspx
it is possible to add tasks to a post build event.
I have created a solution with two projects. One for the Test dll and one for a Windows Form application. I have modified the windows form application project file as described in the article above as follows
<UsingTask TaskName="MyTasks.SimpleTask3" AssemblyFile="bin\debug\MyTasks.dll" />
<Target Name="AfterBuild">
<SimpleTask3 MyProperty="Hello!" />
</Target>
and created a task like this.
using System;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System.Resources;
namespace MyTasks
{
public class SimpleTask3 : Task
{
private string myProperty;
[Required]
public string MyProperty
{
get { myProperty; }
set { myProperty = value; }
}
public override bool Execute()
{
return true;
}
}
}
If I build the task project with return true, then build the Windows Form project, the build succeeds. If I then rebuild the task, then attempt to rebuild the Windows Form project, I get the following error:
Error 1 The command "copy "C:\MyTasks\bin\Debug\MyTasks.dll" "C:\TestApplication\bin\Debug\"" exited with code 1. TestApplication
The only way to get the build to succeed again is to close the solution and re-build. Is this expected behavior? Is there some way to get around this? Having to close and re-open the solution every time the task is changed is annoying.
EDIT:
After some research, trying xcopy, etc... I found that the error has to do with the fact that the MyTask.dll is "in use". Is there a way to force Visual Studio to release the lock on this? This isn't a problem on other projects where there are project references to a dll wit "Copy Local" turned on...
modified 30-Nov-11 12:05pm.
|
|
|
|
|
When i wanna to run script of create/Alter View i get the following error :
My Source is :
SqlConnection con = new SqlConnection(conString);
SqlCommand cmd = new SqlCommand();
try
{
string command = @"create view d_jest
as
SELECT dbo.AccDocumentDetailsVosoolBargasht.VosoolBargashtId, dbo.AccDocumentDetailsVosoolBargasht.AccDocumentDetailsId,
dbo.VosoolBargasht.GhabzDetailsId, dbo.VosoolBargasht.Type, dbo.AccDocumentDetail.AccDocumentID
FROM dbo.AccDocumentDetailsVosoolBargasht INNER JOIN
dbo.VosoolBargasht ON dbo.AccDocumentDetailsVosoolBargasht.VosoolBargashtId = dbo.VosoolBargasht.ID INNER JOIN
dbo.AccDocumentDetail ON dbo.AccDocumentDetailsVosoolBargasht.AccDocumentDetailsId = dbo.AccDocumentDetail.ID
Go
Create view d_kest
as
SELECT dbo.AccDocumentDetail.AccDocumentID, dbo.AccdocumentDetailsTafsiliShenavar.TafsiliShenavarId,
dbo.AccdocumentDetailsTafsiliShenavar.AccDocumentDetailId, dbo.AccdocumentDetailsTafsiliShenavar.ID, dbo.TafsiliShenavar.Name,
dbo.TafsiliShenavar.Code
FROM dbo.AccdocumentDetailsTafsiliShenavar INNER JOIN
dbo.TafsiliShenavar ON dbo.AccdocumentDetailsTafsiliShenavar.TafsiliShenavarId = dbo.TafsiliShenavar.ID INNER JOIN
dbo.AccDocumentDetail ON dbo.AccdocumentDetailsTafsiliShenavar.AccDocumentDetailId = dbo.AccDocumentDetail.ID
Go ";
cmd.CommandText = command;
cmd.Connection = con;
con.Open();
int result = cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
if (con.State == ConnectionState.Open)
con.Close();
I get this error :
Incorrect syntax near 'GO'<br />
'CREATE VIEW' must be the first statement in a query batch.<br />
Incorrect syntax near 'GO'
but if i run this script directly in sql i wont get an error and every thing is right there.
|
|
|
|
|
Go is a special word use by SQL Server. It's not part of the T-SQL language per-se, so you can't use it as part of your command text. An easy way to do this is to split the command text out and issue 2 ExecuteNonQuery commands.
|
|
|
|
|
I have just give here two create view..
I have about 100 views to be create ... so i cannot split it (it will take a lot of time and mistake) i wanna to have all in open command text.
Thanks for reply.
Help Please,
modified 30-Nov-11 6:31am.
|
|
|
|
|
Replace the GO statements with ; instead then.
|
|
|
|
|
i get error.
the error is :
Incorrect syntax near the keyword 'Create'
Thanks for reply.
Please Help!
|
|
|
|
|
Hmmm. OK, with a slight change of architecture, you can use the SMO objects in Microsoft.SqlServer.Management.Common and use ServerConnection.ExecuteNonQuery to execute the original (with GO) statements as that does recognise them.
|
|
|
|
|
will you please make the changes to my code ...
Please.
So i can understand better.
|
|
|
|
|
No. I've given you all the information you need to find this out - I've told you namespaces, and given you classnames to lookup. I am not writing your code for you.
|
|
|
|
|
why not i am confused now.
Please do that favor for me
|
|
|
|
|
I think you have mistaken what these forums are for. This is not rentacoder, and you will not learn anything by me writing your code for you. Take this opportunity to learn something; read up on the SQL Management Objects and how they work. You are wasting time arguing for me to write the code for you - if it were a more complex/interesting problem, I might have taken the time because it would be more demanding for you, but because it's actually very trivial I figure you will benefit from learning how to do this.
|
|
|
|
|
but.....
thanks for solution
|
|
|
|
|
You are welcome, and good luck. If you write the code and have problems with it, I will be more than happy to help.
|
|
|
|
|
hi
i have done that just for creating views but for creating SP i get error.
|
|
|
|
|
Excuse me, but who's getting paid to write this code?? If you'd be willing to send Pete a large chunk of your paycheck, then you might persuade his to do it. Otherwise, do what you're getting paid to do, which includes teaching yourself how to do this stuff.
|
|
|
|
|
As noted Go will not work.
So WRITE code that looks for a line with ONLY that on it.
Then that code breaks your script into an array of strings. You then run each of those strings.
|
|
|
|
|
Hi,
I have a developed a winforms app with c# as the language. Integrated a word object model (Microsoft.Interop.Word 12.0 library) to fill in a word document from a word template using bookmarks. The application opens the word document on button click. This workd fine on my local machine, but when installed on a CITRIX server it is giving an error on button click (Null reference exception). The word doc opens fine when the button is clicked once, but when i close the word doc and re-click on the same button its throwing an exception.
private void btn_Click(object sender, EventArgs e)
{
oWordApp = new Word.Application();
oWordDoc = new Word.Document();
object missing = System.Reflection.Missing.Value;
object oTemplate = "C:\\Program Files\\MyTemplate.dot";
oWordDoc = oWordApp.Documents.Add(ref oTemplate, ref missing, ref missing, ref missing);
object oBookMark = "Date";
oWordDoc.Bookmarks.get_Item(ref oBookMark).Range.Text = DateTime.Now.ToShortDateString();
oWordApp.Application.Visible = true;
oWordApp.WindowState = Word.WdWindowState.wdWindowStateNormal;
}
Does any one know how to resolve this issue?
modified 30-Nov-11 6:32am.
|
|
|
|
|
The first thing you need to do is add some code to find out which object is giving the null reference, and then figure out why. Are you certain that everything is correctly installed on the other system to support your app?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|