Here's the code:

Private Sub btdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btdAdd.Click

        'Sets up the connection to the database
        'Dim myConn As New OleDb.OleDbConnection()

        'Dim sql As String


        con.Open()
        Dim cmd As New OleDb.OleDbCommand ("INSERT INTO   Contacts(Company, First, Last, Title, Address, City, State," & _
               "ZipCode, OfficePhone, CellPhone, AssitantPhone, Fax,   [INDENT][/INDENT]Website, Country, Debt," & _
                [INDENT][/INDENT]"Equity, Mezzanine, Credit [INDENT][/INDENT]Enhancement)" & _
                       "VALUES('" & txtcompadd.Text & "', '" & txtFname.Text & "'," & _
                        "'" & txtLName.Text & "'," & _
                        "'" & txtTitleadd.Text & "', '" & txtaddressadd.Text & "'," & _
                        "'" & txtCityAdd.Text & "', '" & cbStateadd.Text & "'," & _
                        "'" & txtZipAdd.Text & "', '" & txtOffice.Text & "'," & _
                        "'" & txtCell.Text & "', '" & txtAssistant.Text & "'," & _
                       "'" & txtFaxAdd.Text & "', '" & txtWebAdd.Text & "'," & _
                       "'" & cbCountryAdd.Text & "', '" & cbdebt.CheckState & "'," & _
                       "'" & cbequity.CheckState & "', '" & cbmezzanine.CheckState & "'," & _
                        "'" & cbcredit.CheckState & "')"

I'm getting the error: Syntax error in INSERT INTO statement.

The SQL looks correct after removing all of the VB code. But there is no way to know what the functions cbdebt, cbequity, cbmezzanine, and cbcredit are returning. I would recommend saving the insert command text into a variable and posting that back to this thread. When you have that value, you might also try to run the insert command directly into what ever database you are using. I use MSSQL and find that taking my SQL statements directly into MSSQL and execute them there, I find many mistakes that would be very hard in VB, assuming that the error you posted is truly an error in the input statement.

Use parametrized query.

Dim cmd As New OleDb.OleDbCommand ()
 cmd.Connection=con
 cmd.CommandText="INSERT INTO   Contacts ([Company], [First], [Last], [Title], [Address], [City], [State],[ZipCode], [OfficePhone], [CellPhone], [AssitantPhone], [Fax],[Website], [Country], [Debt],[Equity], [Mezzanine], [CreditEnhancement]) VALUES(@Company, @First, @Last, @Title, @Address, @City, @State,@ZipCode, @OfficePhone, @CellPhone, @AssitantPhone, @Fax,@Website, @Country, @Debt,@Equity, @Mezzanine, @CreditEnhancement)"

 cmd.Parameters.AddWithValue("@Company",txtcompadd.Text)
 ....
 con.Open()
 cmd.ExecuteNonQuery();
 con.Close()
 ....
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.