Wie kann ich mit VBNet Daten in SQL Server einfügen?
Ich bin neu invb.net
Ich muss Daten in die Tabelle einfügen, indem ich vb.net benutze. Bitte kann mir jemand helfen
Ich habe das versucht
Hier habe ich Sample Code ausprobiert
Ich habe diese Ausnahme bekommenColumn name or number of supplied values does not match table definition.
danke vorab
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim strName As String = txtName.Text
Dim strId As String = txtID.Text
Dim strPhone As String = txtPhone.Text
Dim strBranch As String = cmboxBranch.SelectedItem.ToString()
Dim strCourse As String = cmbboxCourse.SelectedItem.ToString()
Dim dblFee As Double = Double.Parse(txtFee.Text)
Dim strCommand As String = "insert into student values('" & strName & "','" & strId & "','" & strPhone & "','" & strBranch & "','" & strCourse & "'," & dblFee & ")"
Dim command As SqlCommand = New SqlCommand(strCommand, connection)
command.CommandType = CommandType.Text
'' MsgBox(strCommand)
connection.Open()
If (command.ExecuteNonQuery().Equals(1)) Then
MsgBox("Information stored in database")
Else
MsgBox("Not stored in database")
End If
End Sub