2
Answers

Passing datatable as parameter to stored procedure

Photo of Suraj Kumbhar

Suraj Kumbhar

8y
207
1
Hello,
I have three tables as one master and 2 details table.  I want to save data in all three tables by passing single datatable as parameter to stored procedure. 
Can anybody tell me how to do that??
How to store values from one table to all three different tables??

Answers (2)

0
Photo of Soft Corner
NA 3.1k 484.2k 13y
Hi,
 Try this Code :
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=DBNAME;Integrated Security=true;");

SqlDataReader dr;
SqlCommand cmd;

try
{
  con.Open();
  string qry ="select * from table where username ='"+textbox1.Text+"'";
  cmd = SqlCommand(qry,con);
  dr = cmd.ExecuteReader();
 while(dr.read())
  {
    //do something
   
MessageBox.Show("UserName:"+dr.GetString(0));
  }
  dr.Close();
  con.Close();
}
catch(Exception ex)
{
  MessageBox.Show(ex.message);
}
finally
{
con.Close();
}
Accepted
0
Photo of Abhimanyu K Vatsa
NA 50.9k 12.4m 13y
i think you are wishing to search out the record when user type in textbox and clicks button, isn't it? if so then read a article which let u find record from database

read this