working with dataset

  • Thread starter Thread starter kalaivanan
  • Start date Start date
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
 
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
 
Back
Top