0
String insertQuery= "INSERT INTO"+ Table_Name +"(Coloum1, Coloum2, Coloum3, Coloum4,Coloum5,Coloum6,Coloum7,Coloum8,Coloum9) VALUES('fname','lname','dob','address','pin','city','tel','eid','date')" ;       
sd.execSQL(insertQuery);

I want to write in sqlite db throu this code but it throws an exception:

08-24 09:51:53.858: E/(595): Exception   android.database.sqlite.SQLiteException: near "INTORegistrationTable11": syntax error: , while compiling: INSERT INTORegistrationTable11(Coloum1, Coloum2, Coloum3, Coloum4,Coloum5,Coloum6,Coloum7,Coloum8,Coloum9) VALUES('fname','lname','dob','address','pin','city','tel','eid','date')
0

3 Answers 3

1

Look at the SQL it's complaining about "INTORegistrationTable11"

See the lack of a space?

This:

String insertQuery= "INSERT INTO" + Table_Name + "(Coloum1, ...

should be:

String insertQuery = "INSERT INTO " + Table_Name + " (Coloum1, ...

Reading error messages carefully is an important part of software engineering.

Sign up to request clarification or add additional context in comments.

Comments

0
String insertQuery= "INSERT INTO "+ Table_Name +" (Coloum1, Coloum2, Coloum3, Coloum4,Coloum5,Coloum6,Coloum7,Coloum8,Coloum9) VALUES('fname','lname','dob','address','pin','city','tel','eid','date')" ;

Add a space after INTO.

Comments

0

Spaces, be very careful when composing such strings for SQL, always make sure there is proper space before and after each SQL symbol and word. Also, why not use the built in insert() function and provide your data through ContentValues ?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.