Newbee question about SQL and Datagrid

  • Thread starter Thread starter EMW
  • Start date Start date
E

EMW

I've posted serveral times to get an answer, but till now still now
satisfying answers.

Here is my problem:


I have filled a datagrid control with the contents of an Excel sheet.
Over 3500 rows of information.
I used a dataset which I then binded to the control.

That worked.

Now I want to read the (changed) info from the datagrid into a SQL-server
database.
I have had a hard time finding an example that shows me clearly how to do
that.
Most people answered with documents to me, but that didn't make it more
clear.

I think I have to update the dataset with the changed information first, but
how???
Then I think I have to 'write' this dataset to a SQL file, but how???

I hope someone can give me a good and solid example that can teach me on
this stuff...

Thanks,
Eric
 
Hi EMW,

Does this helps you a little bit.
\\\
Public Shared Sub UpdateDataset(ByVal sqlStr As String, ByVal ds As DataSet)
Dim Conn As New SqlConnection(connString)
Try
Dim da As New SqlDataAdapter
da.SelectCommand = New SqlCommand(sqlStr, Conn)
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(da)
If ds.HasChanges Then
da.Update(ds.GetChanges)
End If
Catch sqlExc As SqlException
MessageBox.Show(sqlExc.ToString, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Catch ex As Exception
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK,
MessageBoxIcon.Error)
Finally
Conn.Close()
End Try
End Sub
///
Cor
 
Hi Cor,

It helps a little, but I'm still confused of what to put in the
connectionstring, since I want everything to be put in the file, I set the
SQLstr on "SELECT *". but for the rest I'm still in the dark...

Can you please help me some more?

thanks.
Eric
 
Hi Eric,
That is the easiest,

"SELECT * FROM tablenaam"

tablenaam is the name of your SQL table.

That is all.

Cor
 
Back
Top