Insert Data directly into database using WinForm DataGrid

danishce

Member
Joined
Apr 2, 2007
Messages
15
Programming Experience
3-5
Hello,
I want to insert data directly into my windows form data grid and load a combobox(userid) in the 1st column of data grid,a textbox(password) in 2nd column of datagrid.
The code for insert data is:
dim cmd as new oledbcommand("insert into table(userid,password) values('" & cmbcol1.text & "','" & txtcol2.text & "')",connection)
dim da as new oledbdataadapter
dim ds as new dataset
da.selectcommand=cmd
da.fill(ds)
messagebox.show "Record Inserted successfully"
I want to insert the data into database so when the user presses the enter key in 2nd column of datagrid(txtcol2.text),the above code for inserting data is executed and cursor moves to second row of 1st column.
can anybody explain me how to achieve this in vb.net 2003 windows form?
Regards:
Danish Majid
 
You want to do what?
Insert data into the grid or the database or the combobox?
INSERT sql are used for inserting into databases, not datagrids or combos..

Confusing post..
Why have a combo?

As a starter, take a read of the DW1 article in my signature
 
Basically i want to save the data that is in the datagrid. I want to load product codes in the 1st cloumn of combobox and save data after user press enter in the combobox but i dont know how to attach this combobox into datagrid and save the value of combobox in keypress event.can you help me?
 
Back
Top