problem getting data from 2 tables match.
I have 2 tables where "userid" is common. first table has Username along with userid. And the second table has loan details along with userid. Now i want to make a search form where the client can enter Username to search for Loan details. How do i do it? It is kinda urgent.
Kirtan PatelPosted Oct 19, 2009, 1:22 PM
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Rows.Count > 0)
{
//show CurrentSelected Row's Column 1 value in TextBox1
textBox1.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
//show CurrentSelected Row's Column 2 value in TextBox2
textBox2.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
}
}
utsav rathourPosted Oct 19, 2009, 1:28 PM
utsav rathourPosted Oct 19, 2009, 1:07 PM
enerally I want to be able to show the data selected from the datagridview( after search) in a text box. for example the amount, or any other data. Could you help me do that and provide me the code. i would love to do it by myself with some help but currently i am runnin out of time.
Thanks
Kirtan PatelPosted Oct 19, 2009, 12:55 PM
to do this we need to fill ds.Table["load"] with query "Select * from loan"
separately because in previous code we have filled the dt with mixed data from both tables "loan" and "debtors"
and if you need more help just let me know i will send you that files with modified code :)
just let me know where you want to update and how you want to update it :)
thank you :)
utsav rathourPosted Oct 19, 2009, 12:48 PM
this.textBox1.Text = ds.Tables["loan"].Rows[this.dataGridView1.CurrentCell.RowIndex][3].ToString();
Now with datatable how do i show this. Sry to bother again.
utsav rathourPosted Oct 19, 2009, 10:43 AM
Kirtan PatelPosted Oct 19, 2009, 9:42 AM
congrats problem solved :)
dont forget to mark "Do you like this answer" please :)
It was Happening Because Your Database Design Was not Correct ..
1. You have Defined AutoNumber type in DebtorID and in Loan Table you have Defined debtor_id as Text DataType ( cause od Error Type missmatch)
2. you have not defined foreign key relation ship between debtors and Loan table
corrected Database is in "Application1" folder
Download Corrected Code
utsav rathourPosted Oct 19, 2009, 9:02 AM
Kirtan PatelPosted Oct 19, 2009, 8:37 AM
can you send me your code in Zip File
just upload it here and Send Me Download link
i will Resolve it Quickly ( [email protected] )
utsav rathourPosted Oct 19, 2009, 8:34 AM
Kirtan PatelPosted Oct 18, 2009, 11:46 PM
utsav rathourPosted Oct 18, 2009, 11:10 PM
utsav rathourPosted Oct 18, 2009, 12:38 PM
Kirtan PatelPosted Oct 18, 2009, 11:47 AM
dont forget to mark "Do you like this answer" if my answer helped you :)
SELECT Table1.userid, Table1.username, Table2.loandetail FROM Table1 INNER JOIN Table2 ON Table1.userid = Table2.userid where Table1.username=