lakkadghat
Member
- Joined
- Jul 26, 2003
- Messages
- 12
Hi
i am trying to update my database by just changing one column in row inside the dataset
the problem is that it is updating the dataset but not updating in the database.
does anyone know where i am lacking because all the refrences available shows me similar codes for updating but i am not able to work it out.
below is the code i have used
Imports System
Imports System.Data
Imports System.Data.SqlClient
Dim strconn As String = "Data source=(local);initial catalog=Taiseer;user id=sa;password=;"
Dim conn As New SqlConnection(strconn)
Dim str As String
Dim da As New SqlDataAdapter()
Dim ds As New DataSet()
Dim dt As New DataTable()
Dim dr As DataRow
str = "Select * from Reg where id=1"
da = New SqlDataAdapter(str, conn)
da.Fill(ds, "dt")
dr = ds.Tables("dt").Rows(0)
dr("col1") = Me.txtbox.Text
method 1
conn.Open()
ds.GetChanges(System.Data.DataRowState.Modified)
da.Update(ds)
conn.Close()
method2
ds.AcceptChanges()
conn.Open()
da.Update(ds, "dt")
conn.Close()
THANKS IN ADVANCE
mU$t@f@
i am trying to update my database by just changing one column in row inside the dataset
the problem is that it is updating the dataset but not updating in the database.
does anyone know where i am lacking because all the refrences available shows me similar codes for updating but i am not able to work it out.
below is the code i have used
Imports System
Imports System.Data
Imports System.Data.SqlClient
Dim strconn As String = "Data source=(local);initial catalog=Taiseer;user id=sa;password=;"
Dim conn As New SqlConnection(strconn)
Dim str As String
Dim da As New SqlDataAdapter()
Dim ds As New DataSet()
Dim dt As New DataTable()
Dim dr As DataRow
str = "Select * from Reg where id=1"
da = New SqlDataAdapter(str, conn)
da.Fill(ds, "dt")
dr = ds.Tables("dt").Rows(0)
dr("col1") = Me.txtbox.Text
method 1
conn.Open()
ds.GetChanges(System.Data.DataRowState.Modified)
da.Update(ds)
conn.Close()
method2
ds.AcceptChanges()
conn.Open()
da.Update(ds, "dt")
conn.Close()
THANKS IN ADVANCE
mU$t@f@