Wednesday, March 7, 2012

get string

hello!

I have a code folow:

public

string GetLink()

{

string ID=Request.QueryString["mabaihat"].ToString();

stringget;

SqlConnection con =newSqlConnection(strconnection);

DataSet ds =newDataSet();

con.Open();

SqlCommand

cmd =newSqlCommand("select link from song where songid="+ID+" ",con);

//

how can I get string of comlumn link?

//

con.Colse();

return get;//string link

}

Hi try this changed code

string ID = Request.QueryString["mabaihat"].ToString();string get;SqlConnection con =newSqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);DataSet ds =newDataSet();

con.Open();

SqlCommand cmd =newSqlCommand("select link from song where songid=" + ID , con);object obj = cmd.ExecuteScalar();if (Convert.IsDBNull(obj) || obj==null)

get =

"";else

get = obj.ToString();

con.Close();

return get;

I have retrived the link through execute scalar method.This will solve your problem

|||thank you very much. i'm will try

No comments:

Post a Comment