SQL error: Incorrect syntax near the keyword 'User'

前端 未结 4 704
滥情空心
滥情空心 2020-11-27 07:04

I am using SQL to insert data to SQL Database file using C# as follows.

    String cs = System.Configuration.ConfigurationManager.ConnectionStrings[\"connect         


        
4条回答
  •  不知归路
    2020-11-27 07:49

    run your query against the database. You can use the declare sql keyword to define your variables and give them values. If you need to figure out the variables values, set a breakpoint at conn.Open and then use the locals window to see what values you are passing in. Another tool at your disposal is the Sql Profiler. You can start a trace then run your program. You should be able to see the query as executed in the profile after the code you have posted has run.

    All of this should help you to figure out what is wrong with your sql when the exception does not provide enough information.

    The Sql Server Management Studio should have highlighted the User keyword in your sql statement, easily showing that you need brackets around it like so: [User]

提交回复
热议问题