How to insert ' into database?
-
http://www.w3schools.com/sql/sql\_select.asp ====== You need a head to program. Cool, fast and sharp.
-
http://www.w3schools.com/sql/sql\_select.asp ====== You need a head to program. Cool, fast and sharp.
-
A good link However, i would like to know how to insert char(') into database? e.g Insert into table1 values (''','hhhh') it causes exception THanks
-
this.SqlConnection = new System.Data.SqlClient.SqlConnection(); cmd = new SqlCommand("INSERT INTO TableName (intColumnA, chrColumnB) VALUES (1,'XYX')",this.SqlConnection); cmd.ExecuteNonQuery(); What exception did you get? ====== Yo need a brain to code.
-
sorry I would know to how to insert the character "'" (single quotation character) into the database varchar field. Thanks!
Use 4 apostrophes, one for open string, two for the apostrophe and one for the close string. If the apostrophe exists in the middle of a string do something like this: 'doesn''t' Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
Use 4 apostrophes, one for open string, two for the apostrophe and one for the close string. If the apostrophe exists in the middle of a string do something like this: 'doesn''t' Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
sorry I would know to how to insert the character "'" (single quotation character) into the database varchar field. Thanks!
Just create a function that replaces all your ' (single apostrophe) with '' (TWO single apostrophe), i.e. [Joe O'Connell] becomes [Joe O''Connell] However, I do recommend using Data Adapters and SQLCommands to pass your parameters so you don't need to worry about this anymore. It does make my life easier aside from being safer from SQL injection.
-
Just create a function that replaces all your ' (single apostrophe) with '' (TWO single apostrophe), i.e. [Joe O'Connell] becomes [Joe O''Connell] However, I do recommend using Data Adapters and SQLCommands to pass your parameters so you don't need to worry about this anymore. It does make my life easier aside from being safer from SQL injection.
-
Insert into table1 values ('''','hhhh') i.e. replace ' by '' (quote by quote quote)