P.S. Using the technique above you can write a library routine that will even create the SQL statement, and you could simply pass it a reference to any DataGridView and the name of the table into which to sert the data, and never (hardly ever) write an INSERT statement again:
String query = "INSERT INTO test(itemcode,description,quantity,unit) VALUES (itemcode,description,quantity,unit)";
Won't work. C# isn't going to magically convert the variable names in th VALUES clause to the appropriate things.
Best approach would be to make the list in the VALUES clause use parameters.
"INSERT INTO test(itemcode,description,quantity,unit) VALUES ( @itemcode,@description,@quantity,@unit)"
//What is a MySqlCommand? System.Data.SqlCommand is a sealed class, so you can't derive from it...
MySqlCommand command = new MySqlCommand(query, connection);
command.Parameters.Add( new SqlParameter("@itemcode",itemcode);
... the rest, in order...
I would suppose that one other likely cause is that your MySqlCommand Class is flawed, and the constructor
1) Check if row.Cells[X].Value is null or DBnull before converting or ToString()ing them
2) Catch also (Exception ex) and System.Diagnostics.Debug.WriteLine("Error! Source: ", ex.Source + ", Message: " + ex.Message); to see what happened. You can also do this:
1) FormClosing event occures before FormClosed event.
2) You create the Second Form in your First Form's closing event where GarbageColelctor destroyes the Second Form after the First Form is closed.
3) You should do:
I've 2 Table , table1 id_main[int], Id_detail table2 Id_detail[int] , goods[nvarchar] and there is a relation between table1.Id_detail and table2.Id_detail
now in the form :
i use a textbox for id_main and a combobox for goods to show it
i want to use a button to move between records for e.g. next ,
in form1_load i wrote :
SqlDataReader drSQL;<br />
string strID;<br />
string strID;<br />
strSQL = "SELECT * FROM table1";<br />
SqlCommand cmd = new SqlCommand(strSQL,myconnection);<br />
drSQL = cmSQL.ExecuteReader();<br />
if (drSQL.Read())<br />
txtIndex.Text = drSQL["id_main"].ToString();<br />
strID = drSQL["Id_detail"].ToString();<br />
//this is a function for getting name of goods<br />
FindItemByID(cbxGoods, strID)<br />
in Next_click (...) event , How can navigate between record .
I've done a bit of searching to see what I can find, but not much is appearing. What I'm looking to do is create a small application that will remember icon positions for me (on my desktop). Yes, there are a hundred of these apps out there, but I want to go about it differently than any of the apps I've used.
So, can anyone give me any ideas or pointers to where icon position is stored, and how I can access/change it?
this is a very complex matter, that involves many P/Invoke functions, and consists
of the following steps:
1. find the handle to the listview: in Windows XP the desktop is a listview; to get there,
you must descend the chain "Progman", "SHELLDLL_DefView", "SysListView32".
2. for each of the icons, send an LVM_GETITEMPOSITION or LVM_SETITEMPOSITION message.
Since the message goes to another process and requires a data pointer, that data pointer
must be valid in the other process, so you must first allocate memory in that process.
You will probably need the following prototypes:
Hahah... yeah, I've never had auto-arrange on. No, I'm looking for something a bit more dynamic than that. I'm [hopefully] building a system that will let me classify my desktop icons (whether its a shortcut, folder, or file) and group them dynamically.
But, I have a lot to learn first, so that first reply was a perfect roadmap for me.
Last Visit: 31-Dec-99 18:00 Last Update: 4-Oct-23 18:05