Click here to Skip to main content
14,970,515 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
MySQL for Visual Studio
Error
Unable to save object with error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1

Above is the error message that I get when creating a new datatable in MySQL. I am using Visual Studio 2019. I haven't created any datatable till now and I am getting this error right after my first try.

I have tried to create datatable from Designer itself.

How can I get rid of this error?

What I have tried:

I have tried 'everything' available on the internet.

I tried to input the name as ActKeys, then ActiKeys, then ActivKeys and then ActivationKeys. But still I get the same error. Are these reserved words? I also tried setting the name as Table1.
Posted
Updated 9-Jul-20 22:23pm
v5

Quote:
I have tried literally everything available on the internet.
I very much doubt that; have you checked the MySQL documentation? And since you have not shown us the actual statement that caused the error it is impossible to help you. Please do not post images on other sites. Edit your question and show us the code, the exact SQL statement, and the corresponding error message.
   
Comments
D J Code 3-Jul-20 11:08am
   
@Richard: I didn't use any statement. I just right clicked and clicked create table. The link just shows the image of the error. Pls click on it.
Richard MacCutchan 3-Jul-20 11:50am
   
Then some part of the table definition contains illegal characters, or possibly reserved words.
OriginalGriff 3-Jul-20 11:12am
   
You need to keep up with Yoof culture: "literally" doesn't mean what it says in the dictionary. To the YoT it literally means "nothing". :sigh:
D J Code 3-Jul-20 11:16am
   
I have already stated that I haven't used any code. I have tried to create datatable from Designer itself.
Richard MacCutchan 3-Jul-20 11:51am
   
I am literally amazed. :)
D J Code 4-Jul-20 2:23am
   
@Richard: It is the same with me. :O
The error message is as clear as it can be: your SQL command is wrong near to a closing bracket.

Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. And without any idea of what your code looks like, we can't even start to fix it.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
When you get to the DataAdapter.Fill line, look at exactly what string you have set as the Command and compare that to proper SQL syntax for the command you are using - at a guess that's a SELECT and it isn't usually too difficult to see what is wrong with those.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
   
Comments
D J Code 3-Jul-20 11:15am
   
@OriginalGriff: I have already stated that I haven't used any code. I have tried to create datatable from Designer itself.
OriginalGriff 3-Jul-20 11:33am
   
Not to me ...

Then check your table definition: are you using any MySql reserved words as column names? Any columns with spaces or other special characters?
We can't check any of this for you!
D J Code 4-Jul-20 2:23am
   
@OriginalGriff: I tried to input the name as ActKeys, then ActiKeys, then ActivKeys and then ActivationKeys. But still I get the same error. Are these reserved words? I also tried setting the name as Table1.
OriginalGriff 4-Jul-20 3:42am
   
What is the exact command string you see in the debugger?
We can't see your screen, we can't access your DB!
D J Code 4-Jul-20 7:18am
   
@OriginalGriff: Pls cool down and try to understand my problem from the root. I don't access the debugger, I don't create queries, I don't enter anything. I just open server explorer toolbar in VS2019, then I connect to my Server & Database & try to create a datatable by right clicking Tables section under my Database and click on create table. Here is where I am not able to save. I press ctrl+s and I get the error message that I have posted as an image link.
Thank you everyone for the support and time spent to help me. Finally I found the solution myself.

I used the MySQL WorkBench to create datatables and views and that solved my problems.

If anyone faces any such problem, the easiest solution is to use the MySQL WorkBench.

Then you can view it and also edit it in Visual Studio & connect to it through code.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900