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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajeesh MenothPosted Mar 8, 2016, 10:46 AM
sruthy sebinPosted Mar 8, 2016, 9:22 AM
sruthy sebinPosted Mar 5, 2016, 4:37 AM
Rajeesh MenothPosted Mar 5, 2016, 4:24 AM
Amit Kumar SinghPosted Mar 5, 2016, 2:16 AM
sruthy sebinPosted Mar 5, 2016, 2:08 AM
Amit Kumar SinghPosted Mar 5, 2016, 1:43 AM
sruthy sebinPosted Mar 5, 2016, 1:32 AM
Amit Kumar SinghPosted Mar 5, 2016, 12:55 AM
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 sebinPosted Mar 5, 2016, 12:43 AM