types and untyped dataset and access the right column

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
 
N

Nicholas Paldino [.NET/C# MVP]

Nabil,

A typed data set is basically a derivation from data set, where the
tables are exposed as properties and the rows have properties representing
the fields. In order to generate one, you will have to go to server
explorer and drag the tables into a dataset. Basically, add a dataset to
your project, and then drag the tables onto it, and you should be able to
use it then.

Hope this helps.
 

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

Top