P
phenderson
Hi,
I'm fairly new to vb/ado.net and am having a hard time adding a row to
a table. The following code executes without any exceptions, but the
rows do not appear in the database. Also, I've stepped through the
entire thing and the RowState property never changes from "detached".
Any help would be greatly appreciated!
--------------------------------------------------------------------------------------------------------------------
Dim retList as array
Dim strArray as Object
Dim i as Integer
Dim cnConn As New SqlConnection
Dim da As SqlDataAdapter
Dim ds As DataSet
Dim dt As DataTable
Dim dr As DataRow
Dim drc As DataRowCollection
cnConn.ConnectionString = _
"Data Source=" & strServer & ";" & _
"Initial Catalog=" & strDatabase & ";" & _
"Integrated Security=SSPI"
cnConn.Open()
da = New SqlDataAdapter("select * from tProviders", cnConn)
ds = New DataSet("tProviders")
da.Fill(ds, "tProviders")
dt = New DataTable
dt = ds.Tables("tProviders")
drc = dt.Rows
For i = (LBound(retList) + 1) To UBound(retList)
strArray = Split(retList(i), "^")
dr = dt.NewRow
drc.Add(strArray)
Next
--------------------------------------------------------------------------------------------------------------------
I'm fairly new to vb/ado.net and am having a hard time adding a row to
a table. The following code executes without any exceptions, but the
rows do not appear in the database. Also, I've stepped through the
entire thing and the RowState property never changes from "detached".
Any help would be greatly appreciated!
--------------------------------------------------------------------------------------------------------------------
Dim retList as array
Dim strArray as Object
Dim i as Integer
Dim cnConn As New SqlConnection
Dim da As SqlDataAdapter
Dim ds As DataSet
Dim dt As DataTable
Dim dr As DataRow
Dim drc As DataRowCollection
cnConn.ConnectionString = _
"Data Source=" & strServer & ";" & _
"Initial Catalog=" & strDatabase & ";" & _
"Integrated Security=SSPI"
cnConn.Open()
da = New SqlDataAdapter("select * from tProviders", cnConn)
ds = New DataSet("tProviders")
da.Fill(ds, "tProviders")
dt = New DataTable
dt = ds.Tables("tProviders")
drc = dt.Rows
For i = (LBound(retList) + 1) To UBound(retList)
strArray = Split(retList(i), "^")
dr = dt.NewRow
drc.Add(strArray)
Next
--------------------------------------------------------------------------------------------------------------------