|
Create some kind of datasource, like a DataTable, and put your data in that, then bind the DataGrid to it.
|
|
|
|
|
Hi,
Is there a metod to hook to CreateWindow, or WM_CREATE in C#?
|
|
|
|
|
|
I use code to insert data from a mdb file into another using the Merge() method of a DataSet...But it's not very effective in terms of performance. Is it possible to use a sql query to directly insert the data? I don't know how to create the code to link the databases.
public void MergeTables(string connS1, string connS2)<br />
{<br />
string connString1 = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + connS1;<br />
string connString2 = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + connS2;<br />
OleDbConnection oleConn1 = new OleDbConnection(connString1);<br />
OleDbConnection oleConn2 = new OleDbConnection(connString2);<br />
string cmd1 = "SELECT *FROM db1_table1";<br />
string cmd2 = "SELECT *FROM db2_table1";<br />
OleDbDataAdapter da1 = new OleDbDataAdapter(cmd1, oleConn1);<br />
OleDbDataAdapter da2 = new OleDbDataAdapter(cmd2, oleConn2);<br />
DataSet ds1 = new DataSet();<br />
da1.Fill(ds1, "db1_table1");<br />
da2.Fill(ds1, "db2_table1");<br />
<br />
ds1.Tables["db1_table1"].Merge(ds1.Tables["db2_table1"]);<br />
<br />
foreach (DataRow row in ds1.Tables["db1_table1"].Rows)<br />
row.SetAdded();<br />
<br />
OleDbCommandBuilder cmdBld = new OleDbCommandBuilder(da1);<br />
da1.UpdateCommand = cmdBld.GetUpdateCommand();<br />
@da1.Update(ds1, "db1_table1");<br />
}
Thank you
|
|
|
|
|
To create an exception if you're not going to throw it? I have column level processing, and line level. The LineException has zero to many ColumnExceptions. If I catch an exception on a column, it gets added to the LineException's collection, which will guarantee the throwing of the LineException, but it just 'looks rude' to me to be creating the LineException before any exception is caught.
Pits fall into Chuck Norris.
|
|
|
|
|
Use lazy instantiation to create the LineException on the first ColumnException as in:
private void AddColumnException(ColumnException ex)
{
if (_lineException == null)
_lineException = new LineException();
_lineException.Add(ex);
}
|
|
|
|
|
Brady Kelly wrote: but it just 'looks rude' to me to be creating the LineException before any exception is caught.
I don't know what you mean by rude. Perhaps you mean it makes the code difficult to understand? If so then that is a problem you should fix if possible.
Are these exceptions being thrown by libraries you are consuming? If not and you are checking conditions and throwing the exceptions yourself then you are probably abusing exceptions.
led mike
|
|
|
|
|
I most certainly am abusing exceptions, , although it will in the near future be highly likely that some of them will be thrown by libraries.
Pits fall into Chuck Norris.
|
|
|
|
|
Throwing an empty LineException for no reason would be rude.
If the user never sees the LineException when it contains no ColumnExceptions, then it's not rude.
|
|
|
|
|
You can always throw LineExceptionByTheWayIAmSorry instead.
|
|
|
|
|
hi..i need to add an cursor to my project.I have an cursor file with me(*.cur).How to add it to my project resource and use it as my form cursor.....in normal case we are using 'this.Cursor=Cursors.None' like that...right ?
modified on Thursday, April 10, 2008 9:33 AM
|
|
|
|
|
Hi Friends,
I want to scan the file before upload on the server using c# and .net.
Can anyone help on this.
Please send me the useful link or suggestions.
Thnaks and Rgds
Nithin.
|
|
|
|
|
Of course there's nothing in the naked .NET framework for virus scanning. You'll need to either find a virus scanning API, or alternately, use an existing virus scanner and Process.Start it onto the file you want to scan.
|
|
|
|
|
Is their some sort of doo-dad that I could, e.g. implement the three default constructors on a derived exception? CodeRush?
Pits fall into Chuck Norris.
|
|
|
|
|
Would a Visual Studio code snippet work?
|
|
|
|
|
Yes in fact it would.
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
Judah Himango wrote: Would a Visual Studio code snippet work?
depends on the author I guess.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
That's a situation where virtual constructors would be a good thing.
But C# doesn't have them.
|
|
|
|
|
Hi,
I am writing an application in which I have to add different worksheets to a workbook in excel. I would like the code to insert in this line: wbk.Worksheets.Add(, , , );. It is expecting a (Object Before, Object After, Object Count, Object Type). Should I use this code to add the worksheet? If not, please advise. The code I have so far is below:
Microsoft.Office.Interop.Excel.Workbook wbk = _appClass.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
...
...
wbk.Worksheets.Add(, , , );
Please Help!!
Mvelo Walaza
Developer
Telkom SA
|
|
|
|
|
Hi all,
I would like to know whether it is possible to access form components from a class which is in another namespace. If not why did they decide to develop C# like that?
Many Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: I would like to know whether it is possible to access form components from a class which is in another namespace
Yes.
|
|
|
|
|
Thanks you for the reply Pete.
Is it possible that you could perhaps give me an example or a link of which you may know where I can see such an occurance?
Many thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Hmmm.
namespace MyNamespace1
{
public partial class MyForm : Form
{
MyForm()
{
....
}
public string MyValue{ get ; set; }
}
}
namespace MyNamespace2
{
public partial class MyForm2 : Form
{
private MyNamespace1.MyForm _form
public MyForm2()
{
_form = new MyNamespace1.MyForm();
_form.MyValue = "Weyhey.";
}
}
}
|
|
|
|
|
Hmmm ... So The code below will create a new instance of the first form, right? Now wouldn't that throw away any data / text that would remain on the first form?
...
private MyNamespace1.MyForm _form
public MyForm2()
{
_form = new MyNamespace1.MyForm();
_form.MyValue = "Weyhey.";
}
...
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
I just showed you how to access a form in a different namespace. How you want to handle it is up to you.
|
|
|
|