1
Answer

Search multiple record by multiple columns

Zuber Kazi

Zuber Kazi

13y
1.4k
1
Hello everyone,
              I create a table customer in sql which contains cust_name,cust_add,cust_mob. Now i entered the values in that table having same cust_name but different cust_add and cust_mob. now I want to search multiple data from my table. I used query-
select * from customer where cust_name in ('RAM','SHYAM')
it returns me all records having cust_name RAM and SHYAM but i want only first records of RAM and SHYAM.
I am confused, how to find that using cust_name and cust_add for multiple records??????

Regards,
Zuber Kazi.
Answers (1)
0
Daniel

Daniel

NA 4 9.9k 14y
        private void cmdSearch_Click(object sender, EventArgs e)
        {
            SqlConnection sqlNWConn = new SqlConnection();
            SqlDataAdapter daCustomers;
            DataSet dsCustomers;
            String tableName = "Customers";

            sqlNWConn = new SqlConnection(@"Data Source=DANS-MAC--WIN7\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True");

                    if (radioAll.Checked == true)
                    {
                        try
                        {
                            sqlNWConn.Open();
                            dsCustomers = new DataSet();                                                // Creates a new DataSet
                            daCustomers = new SqlDataAdapter("select * from Customers", sqlNWConn);     // Creates a new SqlDataAdapter with select command and connection
                            SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daCustomers);             // Fills in insert, update, and delete commands
                            daCustomers.Fill(dsCustomers, tableName);                                   // Fills the dataset
                            dataGridCustomers.DataSource = dsCustomers;
                            dataGridCustomers.DataMember = tableName;
                        }
                        catch
                        {
                            MessageBox.Show("there was an error and your code is crap"); // error will be changed when working
                        }
                    }

                    if (radioName.Checked == true)
                    {
                          // Searches value in txtSearch in table Customer ContactName
                    }
          }
0
Sam Hobbs

Sam Hobbs

NA 28.7k 1.3m 14y
You seem to be feeling panicked. Have a little fun with Database Table Update in a DataGridView without Writing Code.
Next Recommended Forum