Home > Software engineering >  In using vb.net - acess insertcommand through dataadapters object attribute is added to the database
In using vb.net - acess insertcommand through dataadapters object attribute is added to the database

Time:10-02

I use vb.net - acess insertcommand through dataadapters object attribute is added to the database record,
Run time is always a string syntax error prompt, don't know what went wrong, please answer!!!!! Urgent
Thank you very much!!!!!
The main code:
Class:
Shared Function to the add () As String
Dim insval As String="'" & amp; Stuname & amp; "', '" & amp; Stusex & amp; "', '" & amp; Stuhousenum & amp; "', '" & amp; Stuhousetype & amp; "', '" & amp; Stuzjtype & amp; "', '" & amp; Stuzjnum & amp; "', '" & amp; Stunum & amp; "', '" & amp; Studata & amp; _
"', '" & amp; Stuphonenum
Dim oledbins As String="insert into the customer (cusname cussex, cushousenum, cushousetype, cuszjtype, cuszjnum, cusnum, cusdata, cusphonenum) values (" & amp; Insval & amp;
")"Dim MSG As String
Try
Conn. The Open ()
Dim inscom As New OleDbCommand (oledbins, conn.)
Dim da As New OleDbDataAdapter
Da. InsertCommand=inscom
Da. InsertCommand. ExecuteNonQuery ()
MSG="records added successfully"
Catch the ex As Exception
MSG=ex. Message
The Finally
Conn. Close ()

End the Try
Return MSG
End the Function

Add the record: If Rad1. Checked=True Then
Student. Stusex="male"
The Else
Student. Stusex="female"
End the If
Student. Stuname=txtname. Text
Student. Stuhousenum=txthousenum. Text
Student. Stuhousetype=Txthousetype. Text
Student. Stuzjtype=Txtzjtype. Text
Student. Stuzjnum=Textzjnum. Text
Student. Stunum=Textcusnum. Text
Student. Studata=https://bbs.csdn.net/topics/Textdata.Text
Student. Stuphonenum=Textphonenum. Text
Dim MSG As String=student. The add ()
MessageBox. Show (MSG, "prompted", MessageBoxButtons. OK, MessageBoxIcon. Information)

CodePudding user response:

Try to write like this:
SQL="insert into the table name (character fields, numeric fields) values ('" & amp; Character variables & amp;" ', "& amp; Numeric variables & amp;" "
  • Related