hello all,

i want to question how to i get value query sql in asp.net c#
example:
this is my sample code:

string no_hp = "";
string queryNoHP = "SELECT NO_HP FROM REF_OWNER WHERE ID = '" + ID.Text + "'";

i want to how to get value from my query, example field NO_HP into my variable (no_hp). Thanks for your help..

>i get value query sql in asp.net c#

ADO.NET database integration class lib is used.

Use SqlCommand and SqlDataReader for this..
like
SqlCommand cmd=new SqlCommand(queryNoHP,urconnobject);
urconnobject.open();
SqlDataReader rd=cmd.ExecuteReader();
if(rd.read())
{
no_hp =rd.GetString(0);
}
-------------------------
i hope this willw work for u..
try it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.