“System.Data.OleDb.OleDbException: 'Syntax error in INSERT INTO statement.'” [duplicate]










2
















This question already has an answer here:



  • OleDBException error INSERT

    2 answers



I've got an error message:




System.Data.OleDb.OleDbException: 'Syntax error in INSERT INTO statement.'




I've read through multiple questions like this, but non of their answers helped me.



This is my code:



conn.Open();

string sql = "";
sql = "insert into player(Username, Password) values(@Username, @Password)";

using (command = new OleDbCommand(sql, conn))

command.Parameters.AddWithValue("@Username", textBoxUsername.Text);
command.Parameters.AddWithValue("@Password", textBoxPassword.Text);
command.ExecuteNonQuery();

command.Dispose();
conn.Close();


The error is in the following line:



command.ExecuteNonQuery();


Does anyone know a solution for this error?



Thanks in advance!










share|improve this question















marked as duplicate by WelcomeOverflow, Community Nov 12 '18 at 21:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2





    What database are you connecting to? Try using values(?, ?) syntax.

    – Alex K.
    Nov 12 '18 at 16:08







  • 1





    OleDb is a very general purpose API that can talk to multiple databases; if you're talking to a specific database, it is usually preferable to use that database's specific API - for example, SqlConnection/SqlCommand etc for SQL Server. This will allow you to use that target database's full set of features, such as named parameters. OleDb is quite... well, minimal, frankly. It doesn't support named parameters, as noted by the existing answer etc.

    – Marc Gravell
    Nov 12 '18 at 16:16






  • 2





    BTW: good job on using parameters in the first place; you'd be amazed how often we see SQL concatenation of values!

    – Marc Gravell
    Nov 12 '18 at 16:17











  • I'm using an Acces database and thus SqlCommand does not work for me. The targetting of the database is not the problem since reading from it works perfectly well. I discoverd my problem was the use of "Password" as column name. Changing this to "Passw" solved it. Thanks for the help anyway!

    – MrrrLuiigii
    Nov 12 '18 at 21:52















2
















This question already has an answer here:



  • OleDBException error INSERT

    2 answers



I've got an error message:




System.Data.OleDb.OleDbException: 'Syntax error in INSERT INTO statement.'




I've read through multiple questions like this, but non of their answers helped me.



This is my code:



conn.Open();

string sql = "";
sql = "insert into player(Username, Password) values(@Username, @Password)";

using (command = new OleDbCommand(sql, conn))

command.Parameters.AddWithValue("@Username", textBoxUsername.Text);
command.Parameters.AddWithValue("@Password", textBoxPassword.Text);
command.ExecuteNonQuery();

command.Dispose();
conn.Close();


The error is in the following line:



command.ExecuteNonQuery();


Does anyone know a solution for this error?



Thanks in advance!










share|improve this question















marked as duplicate by WelcomeOverflow, Community Nov 12 '18 at 21:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2





    What database are you connecting to? Try using values(?, ?) syntax.

    – Alex K.
    Nov 12 '18 at 16:08







  • 1





    OleDb is a very general purpose API that can talk to multiple databases; if you're talking to a specific database, it is usually preferable to use that database's specific API - for example, SqlConnection/SqlCommand etc for SQL Server. This will allow you to use that target database's full set of features, such as named parameters. OleDb is quite... well, minimal, frankly. It doesn't support named parameters, as noted by the existing answer etc.

    – Marc Gravell
    Nov 12 '18 at 16:16






  • 2





    BTW: good job on using parameters in the first place; you'd be amazed how often we see SQL concatenation of values!

    – Marc Gravell
    Nov 12 '18 at 16:17











  • I'm using an Acces database and thus SqlCommand does not work for me. The targetting of the database is not the problem since reading from it works perfectly well. I discoverd my problem was the use of "Password" as column name. Changing this to "Passw" solved it. Thanks for the help anyway!

    – MrrrLuiigii
    Nov 12 '18 at 21:52













2












2








2









This question already has an answer here:



  • OleDBException error INSERT

    2 answers



I've got an error message:




System.Data.OleDb.OleDbException: 'Syntax error in INSERT INTO statement.'




I've read through multiple questions like this, but non of their answers helped me.



This is my code:



conn.Open();

string sql = "";
sql = "insert into player(Username, Password) values(@Username, @Password)";

using (command = new OleDbCommand(sql, conn))

command.Parameters.AddWithValue("@Username", textBoxUsername.Text);
command.Parameters.AddWithValue("@Password", textBoxPassword.Text);
command.ExecuteNonQuery();

command.Dispose();
conn.Close();


The error is in the following line:



command.ExecuteNonQuery();


Does anyone know a solution for this error?



Thanks in advance!










share|improve this question

















This question already has an answer here:



  • OleDBException error INSERT

    2 answers



I've got an error message:




System.Data.OleDb.OleDbException: 'Syntax error in INSERT INTO statement.'




I've read through multiple questions like this, but non of their answers helped me.



This is my code:



conn.Open();

string sql = "";
sql = "insert into player(Username, Password) values(@Username, @Password)";

using (command = new OleDbCommand(sql, conn))

command.Parameters.AddWithValue("@Username", textBoxUsername.Text);
command.Parameters.AddWithValue("@Password", textBoxPassword.Text);
command.ExecuteNonQuery();

command.Dispose();
conn.Close();


The error is in the following line:



command.ExecuteNonQuery();


Does anyone know a solution for this error?



Thanks in advance!





This question already has an answer here:



  • OleDBException error INSERT

    2 answers







c# database






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 17:09









Llazar

9411516




9411516










asked Nov 12 '18 at 16:05









MrrrLuiigiiMrrrLuiigii

143




143




marked as duplicate by WelcomeOverflow, Community Nov 12 '18 at 21:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by WelcomeOverflow, Community Nov 12 '18 at 21:53


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 2





    What database are you connecting to? Try using values(?, ?) syntax.

    – Alex K.
    Nov 12 '18 at 16:08







  • 1





    OleDb is a very general purpose API that can talk to multiple databases; if you're talking to a specific database, it is usually preferable to use that database's specific API - for example, SqlConnection/SqlCommand etc for SQL Server. This will allow you to use that target database's full set of features, such as named parameters. OleDb is quite... well, minimal, frankly. It doesn't support named parameters, as noted by the existing answer etc.

    – Marc Gravell
    Nov 12 '18 at 16:16






  • 2





    BTW: good job on using parameters in the first place; you'd be amazed how often we see SQL concatenation of values!

    – Marc Gravell
    Nov 12 '18 at 16:17











  • I'm using an Acces database and thus SqlCommand does not work for me. The targetting of the database is not the problem since reading from it works perfectly well. I discoverd my problem was the use of "Password" as column name. Changing this to "Passw" solved it. Thanks for the help anyway!

    – MrrrLuiigii
    Nov 12 '18 at 21:52












  • 2





    What database are you connecting to? Try using values(?, ?) syntax.

    – Alex K.
    Nov 12 '18 at 16:08







  • 1





    OleDb is a very general purpose API that can talk to multiple databases; if you're talking to a specific database, it is usually preferable to use that database's specific API - for example, SqlConnection/SqlCommand etc for SQL Server. This will allow you to use that target database's full set of features, such as named parameters. OleDb is quite... well, minimal, frankly. It doesn't support named parameters, as noted by the existing answer etc.

    – Marc Gravell
    Nov 12 '18 at 16:16






  • 2





    BTW: good job on using parameters in the first place; you'd be amazed how often we see SQL concatenation of values!

    – Marc Gravell
    Nov 12 '18 at 16:17











  • I'm using an Acces database and thus SqlCommand does not work for me. The targetting of the database is not the problem since reading from it works perfectly well. I discoverd my problem was the use of "Password" as column name. Changing this to "Passw" solved it. Thanks for the help anyway!

    – MrrrLuiigii
    Nov 12 '18 at 21:52







2




2





What database are you connecting to? Try using values(?, ?) syntax.

– Alex K.
Nov 12 '18 at 16:08






What database are you connecting to? Try using values(?, ?) syntax.

– Alex K.
Nov 12 '18 at 16:08





1




1





OleDb is a very general purpose API that can talk to multiple databases; if you're talking to a specific database, it is usually preferable to use that database's specific API - for example, SqlConnection/SqlCommand etc for SQL Server. This will allow you to use that target database's full set of features, such as named parameters. OleDb is quite... well, minimal, frankly. It doesn't support named parameters, as noted by the existing answer etc.

– Marc Gravell
Nov 12 '18 at 16:16





OleDb is a very general purpose API that can talk to multiple databases; if you're talking to a specific database, it is usually preferable to use that database's specific API - for example, SqlConnection/SqlCommand etc for SQL Server. This will allow you to use that target database's full set of features, such as named parameters. OleDb is quite... well, minimal, frankly. It doesn't support named parameters, as noted by the existing answer etc.

– Marc Gravell
Nov 12 '18 at 16:16




2




2





BTW: good job on using parameters in the first place; you'd be amazed how often we see SQL concatenation of values!

– Marc Gravell
Nov 12 '18 at 16:17





BTW: good job on using parameters in the first place; you'd be amazed how often we see SQL concatenation of values!

– Marc Gravell
Nov 12 '18 at 16:17













I'm using an Acces database and thus SqlCommand does not work for me. The targetting of the database is not the problem since reading from it works perfectly well. I discoverd my problem was the use of "Password" as column name. Changing this to "Passw" solved it. Thanks for the help anyway!

– MrrrLuiigii
Nov 12 '18 at 21:52





I'm using an Acces database and thus SqlCommand does not work for me. The targetting of the database is not the problem since reading from it works perfectly well. I discoverd my problem was the use of "Password" as column name. Changing this to "Passw" solved it. Thanks for the help anyway!

– MrrrLuiigii
Nov 12 '18 at 21:52












1 Answer
1






active

oldest

votes


















1














Change your sql to



sql = "insert into player(Username, Password) values(?, ?)"





share|improve this answer































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Change your sql to



    sql = "insert into player(Username, Password) values(?, ?)"





    share|improve this answer





























      1














      Change your sql to



      sql = "insert into player(Username, Password) values(?, ?)"





      share|improve this answer



























        1












        1








        1







        Change your sql to



        sql = "insert into player(Username, Password) values(?, ?)"





        share|improve this answer















        Change your sql to



        sql = "insert into player(Username, Password) values(?, ?)"






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 12 '18 at 16:22

























        answered Nov 12 '18 at 16:14









        Peter KarmanPeter Karman

        617




        617













            Popular posts from this blog

            Darth Vader #20

            How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

            Ondo