Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is this really the code needed to get a value from SQL?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Is this really the code needed to get a value from SQL?
Divers
Thread ID:
01262166
Message ID:
01262166
Vues:
69
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform