Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 15th, 2013  |  syntax: None  |  size: 1.48 KB  |  views: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. string connstring = "Data Source=localhost\SQLEXPRESS;database=Inventory;User id=raunak;Password=altran123!;" +
  2.                        "Integrated Security=true;" +
  3.                        "User Instance=true;" +
  4.                        //"AttachDBFilename=|DataDirectory|Inventory.mdf;" +
  5.                        "Initial Catalog=Inventory";
  6.             try
  7.             {
  8.             using (SqlConnection connection = new SqlConnection(connstring))
  9.             {
  10.  
  11.                 SqlCommand cmd = new SqlCommand("INSERT INTO Creation (Name,Product,Quantity,Category)" +
  12.                                      "VALUES (@Name,@Product,@Quantity,@Category)", connection);
  13.                 cmd.Parameters.AddWithValue("@Name", textBox1.Text);
  14.                 cmd.Parameters.AddWithValue("@Product", textBox2.Text);
  15.                 cmd.Parameters.AddWithValue("@Quantity", textBox3.Text.ToString());
  16.                 cmd.Parameters.AddWithValue("@Category", textBox4.Text);
  17.                 thisConnection.Open();
  18.                 cmd.ExecuteNonQuery();
  19.             }
  20.         }
  21.         catch
  22.         {
  23.             thisConnection.Close();
  24.         }
  25.        
  26. string connstring = "Data Source=localhostSQLEXPRESS;Initial Catalog=Inventory;User id=raunak;Password=altran123!;";
  27.        
  28. string connstring = "Data Source=localhostSQLEXPRESS;database=Inventory;User id=raunak;Password=altran123!;" + "Integrated Security=true;" + "User Instance=true;" + //"AttachDBFilename=|DataDirectory|Inventory.mdf;" + "Initial Catalog=Inventory";
clone this paste RAW Paste Data