Click here to Skip to main content
15,905,073 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making desktop application using C#.NET and SQL SERVER
I have created form having 2 labels (prospect id and prospect name)with respective comboboxes and used datagrid view...I want that data should be displayed in respective textboxes.I have tried following code but i am not getting data displayed gor prospect_name

SqlConnection con = new SqlConnection("Data Source=SW-PC-20;Initial Catalog=PSM;Integrated Security=True");
            con.Open();

            SqlCommand com = new SqlCommand("select Prospect_ID,Prospect_Name from Filter where Prospect_ID='" + dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() + "'", con);
            SqlDataReader dr = com.ExecuteReader();
            if (dr.HasRows)
            {
                dr.Read();
                cboprospectid.Text = dr[0].ToString();
                cboprospectname.Text = dr[1].ToString();
            }
            dr.Close();
            con.Close();

Now problem is prospect name is not displayed for respective prospect id
Posted

1 solution

You need to read on how to use ADO.NET. Read about ADO.NET here and it will help you.

Look at these:
MSDN: ADO.NET[^]
MSDN: Accessing Data with ADO.NET[^]

The C# Station ADO.NET Tutorial[^]
Using ADO.NET for beginners[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900