Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is this really the code needed to get a value from SQL?
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Is this really the code needed to get a value from SQL?
Miscellaneous
Thread ID:
01262166
Message ID:
01262166
Views:
68
I have been playing around with getting data from SQL, and thinking about how I would go about designing a Data Layer Object. I have always worked with stored procedures, so I am very comfortable with setting up parameters. I do need to ask though .. the following code seems to be a lot of work to pull a single value from SQL? Is this code correct or have I over complicated things?
DataSet ds;
DataTable dt;
DataRow dr;
SqlDataAdapter oDataAdapter;
int lnRecords;
			
ds = new DataSet();
this.map_ConnectToData();

oDataAdapter = new SqlDataAdapter();
oDataAdapter.SelectCommand = new SqlCommand("map_rlb_Logins_validate", this.oConnection);
oDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure ;

oDataAdapter.SelectCommand.Parameters.Add("@tcUserID",SqlDbType.Char, 20).Value = tcLoginID;
oDataAdapter.SelectCommand.Parameters.Add("@tcPassword",SqlDbType.Char, 20).Value = tcPassword;
lnRecords = oDataAdapter.Fill(ds, "cData");

MessageBox.Show(lnRecords.ToString());

dt = ds.Tables["cData"];
dr = ds.Tables[0].Rows[0];
			
MessageBox.Show(dr["cuserid"].ToString());
TIA, -Mark
Next
Reply
Map
View

Click here to load this message in the networking platform