1.11M Members

INSERT INTO statement contain unknown field name

 
0
 

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
 
2
 

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

 
0
 

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.

 
0
 

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.

Question Answered as of 3 Years Ago by debasisdas and Jx_Man
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: