Sql Express 2016 connection string

  • Thread starter Thread starter RattlerrFx
  • Start date Start date
R

RattlerrFx

Guest
Connection string fails to log into the database that I created than attached database within Visual Studio 2015 Community.

SqlConnection conn = new SqlConnection();
DataSet ds = new DataSet();
SqlDataAdapter da;
SqlCommandBuilder cb;

conn.ConnectionString = "Server=(LocalDB)\\MSSQLLocalDB;Integrated Security=True;Database=cloudyhamdb;Data Source=.\\SQLExpress;";
conn.Open();
da = new SqlDataAdapter("select First_Name from clouddata", conn);

cb = new SqlCommandBuilder(da);
da.Fill(ds);

Console.WriteLine("Update command generated by command builder");
Console.WriteLine(cb.GetUpdateCommand().CommandText);

Console.WriteLine("INSERT COMMAND");
Console.WriteLine(cb.GetInsertCommand().CommandText);

Console.WriteLine("DELETE COMMAND");
Console.WriteLine(cb.GetDeleteCommand().CommandText);

Console.WriteLine("Customer name: " + ds.Tables["clouddata"].Rows[0]["First_Name"]);

ds.Tables["clouddata"].Rows[0]["First_Name"] = "Jack";

da.Update(ds, "Customers");

conn.Close();
Console.ReadLine();

Continue reading...
 
Back
Top