Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1.  string sqlText = "INSERT INTO Person VALUES ( '" + txtPersonId1.Text.Trim() + "',' " +  txtPersonName1.Text + "'); ";
  2.     sqlText += "INSERT INTO Person VALUES ( '" + txtPersonId2.Text.Trim() + "',' " +  txtPersonName2.Text + "'); ";
  3.     sqlText += "INSERT INTO Person VALUES ( '" + txtPersonId3.Text.Trim() + "',' " +  txtPersonName3.Text + "'); ";
  4.     sqlText += "INSERT INTO Person VALUES ( '" + txtPersonId4.Text.Trim() + "',' " +  txtPersonName4.Text + "'); ";
  5.  
  6.     SqlConnection connection = new SqlConnection(connectionString);
  7.     SqlCommand command = new SqlCommand(sqlText,connection);
  8.     command.CommandType = CommandType.Text;
  9.     connection.Open();
  10.     int recordsInserted = command.ExecuteNonQuery();
  11.     connection.Close();
  12.  
  13.     MessageBox.Show("Number of records affected : " + recordsInserted.ToString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement