working with dataset

P

puja

hi, here is the code to insert a row and update ur table. I don't know code
to join 2 tables. Its in VB.net but am sure u will get some idea.

Dim myConnection As SqlConnection

Dim mySqlDataAdapter As SqlDataAdapter

myConnection = New SqlConnection("")

mySqlDataAdapter = New SqlDataAdapter("Select * from tblInstallation",
myConnection)

Dim myDataSet As DataSet = New DataSet

Dim myDataRow As DataRow

' Create command builder. This line automatically generates the update
commands for you, so you don't

' have to provide or create your own.

Dim myDataRowsCommandBuilder As SqlCommandBuilder = New
SqlCommandBuilder(mySqlDataAdapter)

' Set the MissingSchemaAction property to AddWithKey because Fill will not
cause primary

' key & unique key information to be retrieved unless AddWithKey is
specified.

mySqlDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

mySqlDataAdapter.Fill(myDataSet, "tblInstallation")

myDataRow = myDataSet.Tables("tblInstallation").NewRow()

myDataRow("StoreCode") = "storeno"

myDataRow("Installer") = Me.tx_installer.Text

myDataRow("dt_stamp1") = Me.lbl_date.Text

myDataRow("Assessor") = Me.tx_assessor.Text

myDataSet.Tables("tblInstallation").Rows.Add(myDataRow)

mySqlDataAdapter.Update(myDataSet, "tblInstallation")

myDataSet = Nothing
 
K

kalaivanan

it works. thankyou.
hi, here is the code to insert a row and update ur table. I don't know code
to join 2 tables. Its in VB.net but am sure u will get some idea.

Dim myConnection As SqlConnection

Dim mySqlDataAdapter As SqlDataAdapter

myConnection = New SqlConnection("")

mySqlDataAdapter = New SqlDataAdapter("Select * from tblInstallation",
myConnection)

Dim myDataSet As DataSet = New DataSet

Dim myDataRow As DataRow

' Create command builder. This line automatically generates the update
commands for you, so you don't

' have to provide or create your own.

Dim myDataRowsCommandBuilder As SqlCommandBuilder = New
SqlCommandBuilder(mySqlDataAdapter)

' Set the MissingSchemaAction property to AddWithKey because Fill will not
cause primary

' key & unique key information to be retrieved unless AddWithKey is
specified.

mySqlDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

mySqlDataAdapter.Fill(myDataSet, "tblInstallation")

myDataRow = myDataSet.Tables("tblInstallation").NewRow()

myDataRow("StoreCode") = "storeno"

myDataRow("Installer") = Me.tx_installer.Text

myDataRow("dt_stamp1") = Me.lbl_date.Text

myDataRow("Assessor") = Me.tx_assessor.Text

myDataSet.Tables("tblInstallation").Rows.Add(myDataRow)

mySqlDataAdapter.Update(myDataSet, "tblInstallation")

myDataSet = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top