help please.. how can i store the selected value from my database to a variable in my c# form... (eg. variable=select idnum from tblename)<--- i know i cant do that.. how can i pass its value?? im talking about a specific value from the database. lets say i log in and the user name is "vegeta" how can i get its idnum and store it in a variable... thanks..
kapojian
0
Junior Poster in Training
Recommended Answers
Jump to PostThis post of yours has no much of a point.
"the selected value from my database"There is no such thing as selected value in dataBase.
Please, be more specific of this issue of yours.
Jump to Postint userID; private void button_GetIdNum(object sender, EventArgs e) { string userName = textBox1.Text; //this is an example, from where you get the name using(SqlConnection sqlConn = new SqlConnection("connString")) { using(SqlCommand cmd = new SqlCommand()) { cmd.CommandText = @"SELECT idnum FROM tablename WHERE name = @name"; cmd.Parameters.Add("@name", SqlDbType.Int).Value …
Jump to PostSpace? What do you mean?
You mean the Field name (column name) has a white space, like:Column Name
I would suggest you to remove spaces. Its not good to have them at all. There can occur problems.
All 10 Replies
Mitja Bonca
557
Nearly a Posting Maven
kapojian
0
Junior Poster in Training
Mitja Bonca
557
Nearly a Posting Maven
MagnetoM
0
Light Poster
Mitja Bonca
557
Nearly a Posting Maven
MagnetoM
0
Light Poster
Mitja Bonca
557
Nearly a Posting Maven
Bridgekeeper
-1
Newbie Poster
MagnetoM
0
Light Poster
kapojian
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.