Link to home
Start Free TrialLog in
Avatar of JustAskMe
JustAskMe

asked on

Convert Sql String to c# string

Whats the correct syntex?
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Using a SqlDataReader object,

SqlConnection conn = new SqlConnection("Connection String");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT FIELD_NAME FROM Database_Name";
SqlDataReader mySqlDataReader = cmd.ExecuteQuery();
if(mySqlDataReader.Read())
    string cSharpString = (string)mySqlDataReader["FIELD_NAME"];
else
    // no Records found, data reader is empty
sCSharpStr = Convert.ToString(Your_SQL_String);

HTH
Ashok
Avatar of JustAskMe
JustAskMe

ASKER

This is what I try to do:

System.Data.SqlTypes.sqlstring to system string
ASKER CERTIFIED SOLUTION
Avatar of Ashok
Ashok
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you trying to read a string of text from a database?  And how?
ashok111: that works!

one small thing more...

string[] SL = Response.Split("<td><a class=");
JustAskMe,

What is the problem?

Ashok
The compiler doesn't like it
the error is that best overload.. excepts...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks