use parameters or replace ' with '' (two of them) and " with ""
Parameters are the proper way to do it though.
e.g
SqlCommand sqlcom = new SqlCommand("insert into table1 (col1, col2) values
(@value1, @value2), new SqlConnection(constring);
sqlcom.Parameters.AddWithValue("@value1", "Danny's Place");
sqlcom.Parameters.AddWithValue("@value2", " 1' 1/2\"");
sqlcom.Connection.Open();
sqlcom.ExecuteNonQuery();
sqlcom.Connection.Close();
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Jerry" wrote:
> Hi,
>
> I am not sure if this the correct group to ask or not, but here it goes. I
> am having problems inserting
> data into MS SQL 2005 vai c#.
>
> I have strings( varchar( 80 )), that have ' and " in them:
>
> 'Danny's Place'
> ' 1' 1/2" '
>
> How do I get SQL in c# to take varchar with ' & " ?
>
> I have found issues in creating column names with / & % as well. Any ideas?
>
> Thanks,
>
> Jerry
>
>
>