Hello,
I have filled a dataset and would like to take that data and pass it to a sql server database on the network
How can I accomplish this task
Thanks,
Rashar
Hello,
I have filled a dataset and would like to take that data and pass it to a sql server database on the network
How can I accomplish this task
Thanks,
Rashar
How to pass data from a dataset directly to SQL 7.0 in VB.NET?
Timothy John Peters
Thanks for your reply.
I tried using the example and modified some code to pass the entire dataset to my sqlServer Table, but it's not working. When I step in my code, I can see that I am pulling my local dataset values.... any suggestions would greatly be appreciated.
Thanks.
'Create a new connection and SQLDataAdapter Dim myNetworkConnection As SqlConnection Dim myNetworkSQLDataAdapter As New SqlDataAdapter Dim myLocalSQLDataAdapter As New SqlDataAdapter Dim myLocalConnection As SqlConnection 'networkmyNetworkConnection =
New SqlConnection("Server=localhost;Database=Tap_Master;Integrated Security=SSPI; Connect Timeout=5") 'localmyLocalConnection =
New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\TAP_Master.mdf;Integrated Security=True;User Instance=True")myNetworkSQLDataAdapter =
New SqlDataAdapter("Select * From tblContacts", myNetworkConnection)myLocalSQLDataAdapter =
New SqlDataAdapter("Select * From tblContacts", myLocalConnection) 'Setup the Datasets Dim myDataSet As DataSet = New DataSet Dim myDataRow As DataRow 'Create automatic update, insert commands Dim myDataRowsCommandBuilder As SqlCommandBuilder = New SqlCommandBuilder(myNetworkSQLDataAdapter) 'Set the MissingSchemaAction property to AddwithKey because fill will not cause primary key 'and unique key information to be retrieved unless AddwithKey is specifiedmyNetworkSQLDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
myLocalSQLDataAdapter.Fill(myDataSet,
"tblContacts")myDataRow = myDataSet.Tables(
"tblContacts").NewRowmyDataRow(
"Cust_Number1") = myLocalSQLDataAdapter.Fill(myDataSet, "Cust_Number1")myDataSet.Tables(
"tblContacts").Rows.Add(myDataRow)MessageBox.Show(
"Record Added")psy_ill
I figured it out...
myDataRow(
"Cust_Number1") = myNetworkDataSet.Tables("tblContacts").Rows(0).Item("Cust_Number1")Yahor Sinkevich
See http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/UpdateDataFromDB.aspx