types and untyped dataset and access the right columns

N

nabil m

hi i have a couple of questions:
1) what is the difference between type and untyped dataset - i would like t
ouse the typed dataset to take adv of intellisense- but the dataset i have
created seems untyped -
herei s my code -
//create myConn to the db and my Select query and execite
SqlConnection myConn = new SqlConnection("");
SqlCommand mySelectCommand = new SqlCommand("SELECT ContactPassword
ContactUserID FROM TABLE WHERE (ContactUserID = @emailAddress)");
mySelectCommand.Connection = myConn;

// let it know about that paramter
mySelectCommand.Parameters.Add(new SqlParameter("@emailAddress",
SqlDbType.VarChar, 50));

//create a sql data adapter
SqlDataAdapter myDataAdapter = new SqlDataAdapter();
myDataAdapter.SelectCommand = mySelectCommand;

//assign the param to the sql params
myDataAdapter.SelectCommand.Parameters["@emailAddress"].Value =
this.TextBoxEmailaddr.Text.Trim();
myConn.Open();

// create a dataset
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet);
myConn.Close()

2) how do i access a column field called : contactPassword in my Table

this.lblPassword.Text =
myDataSet.Tables["TABLE_Contact_Info"].Rows[0]["contactPassword"].ToString();



IT IS NOT working please help thx in advance
 
S

SevDer

For the difference about typed datasets
Please read it @ http://www.sevder.com/default.aspx?show=HowTO.NET
About #2. Give more details like the error message or don't you get
anything at all. (You may loose your dataset in a postback)

--

SevDer
http://www.sevder.com


nabil said:
hi i have a couple of questions:
1) what is the difference between type and untyped dataset - i would like t
ouse the typed dataset to take adv of intellisense- but the dataset i have
created seems untyped -
herei s my code -
//create myConn to the db and my Select query and execite
SqlConnection myConn = new SqlConnection("");
SqlCommand mySelectCommand = new SqlCommand("SELECT ContactPassword
ContactUserID FROM TABLE WHERE (ContactUserID = @emailAddress)");
mySelectCommand.Connection = myConn;

// let it know about that paramter
mySelectCommand.Parameters.Add(new SqlParameter("@emailAddress",
SqlDbType.VarChar, 50));

//create a sql data adapter
SqlDataAdapter myDataAdapter = new SqlDataAdapter();
myDataAdapter.SelectCommand = mySelectCommand;

//assign the param to the sql params
myDataAdapter.SelectCommand.Parameters["@emailAddress"].Value =
this.TextBoxEmailaddr.Text.Trim();
myConn.Open();

// create a dataset
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet);
myConn.Close()

2) how do i access a column field called : contactPassword in my Table

this.lblPassword.Text =
myDataSet.Tables["TABLE_Contact_Info"].Rows[0]["contactPassword"].ToString();



IT IS NOT working please help thx in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top