I dont know what im doing wrong, but the dataadapter, doesnt
find the table im looking for:

Public Shared Function DSet(ByVal ID As Integer, ByVal Name As String, ByVal Address As String, ByVal City As String, ByVal State As String, _
ByVal ZipCode As Integer, ByVal Phone As String) As DataSet
Dim daAdapter As SqlDataAdapter
Dim scConnection As SqlConnection = Nothing
Dim ds As DataSet = Nothing
Try
Dim rCommand As String
rCommand = "INSERT INTO WholeSaler_Details VALUES (" & ID & ", " & Name & ", " & Address & ", " & _
City & ", " & State & ", " & ZipCode & ", " & Phone & ")"
scConnection = GetConnection()
daAdapter = New SqlDataAdapter
ds = New DataSet
daAdapter.InsertCommand = New SqlCommand(rCommand, scConnection)
daAdapter.Update(ds, "WholeSaler_Details")
scConnection.Close()
Return ds

Catch sqlEx As SqlException
MessageBox.Show(sqlEx.Message, _
"Error Encontrado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Return ds
Finally
scConnection.Close()

End Try
End Function

You defined & attached an insert command to your dataadapter. Now when you call the da.Update method, it will look for any new records in your dataset and insert them into your database. The problem of course is you never added any new records into the dataset.

I dont know what im doing wrong, but the dataadapter, doesnt
find the table im looking for:

Public Shared Function DSet(ByVal ID As Integer, ByVal Name As String, ByVal Address As String, ByVal City As String, ByVal State As String, _
ByVal ZipCode As Integer, ByVal Phone As String) As DataSet
Dim daAdapter As SqlDataAdapter
Dim scConnection As SqlConnection = Nothing
Dim ds As DataSet = Nothing
Try
Dim rCommand As String
rCommand = "INSERT INTO WholeSaler_Details VALUES (" & ID & ", " & Name & ", " & Address & ", " & _
City & ", " & State & ", " & ZipCode & ", " & Phone & ")"
scConnection = GetConnection()
daAdapter = New SqlDataAdapter
ds = New DataSet
daAdapter.InsertCommand = New SqlCommand(rCommand, scConnection)
daAdapter.Update(ds, "WholeSaler_Details")
scConnection.Close()
Return ds

Catch sqlEx As SqlException
MessageBox.Show(sqlEx.Message, _
"Error Encontrado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Return ds
Finally
scConnection.Close()

End Try
End Function

Another thing to keep in mind, above where you are creating the rCommand string, you need to supply literals on text and date fields. ex.

rCommand = "INSERT INTO WholeSaler_Details VALUES ('" & ID & "', '" & Name & "', '" & Address & "', '" & _
            City & "', '" & State & "', '" & ZipCode & "', '" & Phone & "')"

Notice the single quote character before each of the variables '

This article has been dead for over six months. Start a new discussion instead.