SQL string value spanning multiple lines in query SQL string value spanning multiple lines in query sqlite sqlite

SQL string value spanning multiple lines in query


SQL Server allows the following (be careful to use single quotes instead of double)

UPDATE UserSET UserId = 12345   , Name = 'J Doe'   , Location = 'USA'   , Bio='my biospans multiplelines!'WHERE UserId = 12345


What's the column "BIO" datatype? What database server (sql/oracle/mysql)? You should be able to span over multiple lines all you want as long as you adhere to the character limit in the column's datatype (ie: varchar(200) ).Try using single quotes, that might make a difference. This works for me:

update table set mycolumn = 'hello world,my name is carlos.goodbye.'where id = 1;

Also, you might want to put in checks for single quotes if you are concatinating the sql string together in C#. If the variable contains single quotes that could escape the code out of the sql statement, therefore, not doing all the lines you were expecting to see.

BTW, you can delimit your SQL statements with a semi colon like you do in C#, just as FYI.


with your VARCHAR, you may also need to specify the length, or its usually good to

What about grabbing the text, making a sting of it, then putting it into the query witrh

String TableName = "ComplicatedTableNameHere";  EditText editText1 = (EditText) findViewById(R.id.EditTextIDhere); String editTextString1 = editText1.getText().toString();  

BROKEN DOWN

String TableName = "ComplicatedTableNameHere";                //sets the table name as a string so you can refer to TableName instead of writing out your table name everytimeEditText editText1 = (EditText) findViewById(R.id.EditTextIDhere);     //gets the text from your edit text fieldfield     //editText1 = your edit text name    //EditTextIDhere = the id of your text fieldString editTextString1 = editText1.getText().toString();      //sets the edit text as a string    //editText1 is the name of the Edit text from the (EditText) we defined above    //editTextString1 = the string name you will refer to in future

then use

       /* Insert data to a Table*/       myDB.execSQL("INSERT INTO "         + TableName         + " (Column_Name, Column_Name2, Column_Name3, Column_Name4)"         + " VALUES ( "+EditTextString1+", 'Column_Value2','Column_Value3','Column_Value4');");

Hope this helps some what...

NOTE each string is within

'"+stringname+"'

its the 'and' that enable the multi line element of the srting, without it you just get the first line, not even sure if you get the whole line, it may just be the first word