Windows form
how to add two column values from a table (database) to textbox in windows form?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
sruthy sebin19 reputationPosted Mar 4, 2016, 7:43 PM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Mar 4, 2016, 7:55 PM EST
chk following code
//for this i used access database and assume you have two txtboxes to take input for Name and Password resp.
oledbConnection conn = new OleDbConnection(strConn); //strConn is your connectionString
string strQuery = "Select Name,Password from Login"; //Table Name : Login with two Clmns:Name and Password
conn.open();
oledbCommand cmd = new OleDbCommand(strQuery,conn);
oledbAdapter adapter = new OleDbAdapter(cmd);
dataset ds = new dataset();
adapter.Fill(ds);
conn.close();
//declare these variables at beginning
string strName;
string strPassword;
string strNameText;
string strPassText;
strNameText = txtName.Text; //textbox from where you r taking i/p
strPassText = txtPassword.text;
if(ds.tables[0].rows.count>0)
{
for(int i=0;i
strName = convert.ToString(ds.tables[0].rows[i]["Name"].tostring()); //fetch Name clm from db
strPasword = convert.ToString(ds.tables[0].rows[i]["Password"].tostring());
if(strNameText == strName && strPassText == strPasword)
{
//correct;
}
else
{
//incorrect
}
}
}
sruthy sebin19 reputationPosted Mar 4, 2016, 8:32 PM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Mar 4, 2016, 8:43 PM EST
sruthy sebin19 reputationPosted Mar 4, 2016, 9:08 PM EST
Amit Kumar SinghRank #562 · 4.3K reputationPosted Mar 4, 2016, 9:16 PM EST
Rajeesh MenothRank #118 · 18.4K reputationPosted Mar 4, 2016, 11:24 PM EST
sruthy sebin19 reputationPosted Mar 4, 2016, 11:37 PM EST
sruthy sebin19 reputationPosted Mar 8, 2016, 4:22 AM EST
Rajeesh MenothRank #118 · 18.4K reputationPosted Mar 8, 2016, 5:46 AM EST