I keep getting the following error when I try to add new record into database (Access 2007)
"The INSERT INTO statement contain unknown field name:'login'."
I dont whats wrong as the coding looks fine and the field login does exist in the database. Spent whole day trying to find the solution, hope someone here can help me.
this are my coding

Imports System.Data.OleDb
Public Class Form1
    Dim connstr, strSQL As String
    Dim myconnection As OleDbConnection
    Dim mycommand As OleDbCommand
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            connstr = "Provider=microsoft.jet.oledb.4.0;data source=C:\Users\Rizal\Documents\Visual Studio 2008\Projects\login\login\login.mdb"
            myconnection = New OleDbConnection(connstr)
            strSQL = "INSERT INTO Table1 ([login],[Pass]) VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "')"
            myconnection.Open()
            mycommand = New OleDbCommand(strSQL, myconnection)
          
            mycommand.ExecuteNonQuery()
            myconnection.Close()
            MessageBox.Show("Data Saved")

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub

change your field name with another name..
This may happen because login word already taken by the system.

commented: agree +9

Even if login is a key word, since it is wrapped with [] there should not be any problem.

check for any mispelled or spaces in the column name.

Better to try using a different name as suggested by Jx.

I changed the field name to People and Secret , It doesnt show the changes I made in database on the data source explorer though. Have to edit the SQL querry manually on the DataSet.xsd. Now it works! Thanks for the responds guys.

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.