Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.59 KB  |  hits: 8  |  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. Inserting into sql server .mdf file does not work
  2. using (SqlConnection sqlConnection = new SqlConnection(@"Data Source=.SQLE;AttachDbFilename=|DataDirectory|DB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"))
  3.         {
  4.             SqlCommand sqlcommand =
  5.                 new SqlCommand("INSERT INTO [Streets] ([name], [highway]) VALUES ('sdsgsdg', 'sdfdsgsdg');",
  6.                                sqlConnection);
  7.             sqlcommand.Connection.Open();
  8.  
  9.             MessageBox.Show(sqlcommand.ExecuteNonQuery().ToString());
  10.             sqlcommand.Connection.Close();
  11.         }