SHARE
TWEET

Untitled

a guest Feb 15th, 2013 38 Never
  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";
RAW Paste Data
Top