I am making the transition from DataTableAdapters in MSVS to creating Stored Procedures in MS SQL Server.
This is what I have so far.
protected void Submit_Click(object sender, EventArgs e)
{
var conString = ConfigurationManager.AppSettings["ConnectionString"].ToString();
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("getAdministrators", con))
{
cmd.Parameters.Add("@userName", SqlDbType.VarChar).Value = userNameTB.Text;
cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = passwordTB.Text;
cmd.CommandType = CommandType.StoredProcedure;
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
DataSet ds = new DataSet();
da.Fill(ds);
}
}
}
}
I want to grab all the rows/columns and store them in a DataSet and use the values returned at my will for whatever I wish. What am I missing to accomplish this. Or if someone has an article that could help as well?
I updated the code to use using.
I think the code is slowly getting there...
usingfor things likeSqlCommand,SqlConnection, etcVarCharand notNVarChar?