[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1796
  • Last Modified:

Convert Sql String to c# string

Whats the correct syntex?
0
JustAskMe
Asked:
JustAskMe
  • 4
  • 4
  • 2
2 Solutions
 
Todd GerbertIT ConsultantCommented:
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
0
 
AshokCommented:
sCSharpStr = Convert.ToString(Your_SQL_String);

HTH
Ashok
0
 
JustAskMeAuthor Commented:
This is what I try to do:

System.Data.SqlTypes.sqlstring to system string
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AshokCommented:
string sCSharpStr = Convert.ToString(Your_SQL_String);

HTH
Ashok
0
 
Todd GerbertIT ConsultantCommented:
Are you trying to read a string of text from a database?  And how?
0
 
JustAskMeAuthor Commented:
ashok111: that works!

one small thing more...

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

What is the problem?

Ashok
0
 
JustAskMeAuthor Commented:
The compiler doesn't like it
the error is that best overload.. excepts...
0
 
AshokCommented:
Check this site

http://dotnetperls.com/string-split

I think Split function takes one character as DEFAULT input (not string).

Ashok
0
 
JustAskMeAuthor Commented:
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now