Hi folks:
Can anyone tell me what I am doing wrong in the coding below:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim ConnectionString As String = "Server=hp;database=library;integrated security=SSPI"
MessageBox.Show("Connection established")
Dim sql As String = "SELECT snippetID, snippetName, snippetSource, snippetCode FROM snippet order by snippetName"
Dim cnn As New SqlConnection(ConnectionString)
Dim cmd As New SqlCommand(sql, cnn)
Dim da As New SqlDataAdapter
Dim ds As New DataSet
cmd.CommandText = sql
da.SelectCommand = cmd
da.Fill(ds, "snippet")
Dim isconnecting As Boolean = True
While isconnecting
Dim str As String = _
"INSERT INTO snippet (snippetName, snippetSource, snippetCode)" & _
"VALUES (@snippetName, @snippetSource, @snippetCode)"
Dim cn As New OleDbConnection(str)
Dim cmdd As New OleDbCommand(str, cn)
With cmdd
.Parameters.Add(New OleDbParameter("@snippetName", _
OleDbType.VarChar, 50)).Value = ds.Tables("snippetName")
.Parameters.Add(New OleDbParameter("@snippetSource", _
OleDbType.VarChar, 50)).Value = ds.Tables("snippetSource")
.Parameters.Add(New OleDbParameter("@snippetCode", _
OleDbType.LongVarWChar)).Value = ds.Tables("snippetCode")
End With
cn.Open()
cmdd.ExecuteNonQuery()
cn.Close()
isconnecting = False
End While
Catch ex As Exception
MsgBox("Error " & ex.Source & " " & ex.Message)
End Try
End Sub