hi guys, in one of my .NET applications I need to connect to localDB but the code I wrote originally was for sql express and now it's returning an error understandly. Does anybody know what's the equivalent of this for localDB please?
protected void submitData(object sender, EventArgs e)
{
hookUp = new SqlConnection("Server=localhost\\SqlExpress;Database=test4;" + "Integrated Security=True");
strInsert = "INSERT INTO Overtime(Week,HrsWorked,Overtime,Comment) VALUES (@week,@hrsWrk,@ovt,@cmmt)";
HrsWorked = Convert.ToDecimal(hrs.Value);
Overtime = HrsWorked - WRKHRS;
sqlCmd = new SqlCommand(strInsert, hookUp);
sqlCmd.Parameters.Add("@week", txtStartDate.Text);
sqlCmd.Parameters.Add("hrsWrk", HrsWorked);
sqlCmd.Parameters.Add("@ovt", Overtime);
sqlCmd.Parameters.Add("@cmmt", TextArea1.Value);
hookUp.Open();
sqlCmd.ExecuteNonQuery();
hookUp.Close();
txtStartDate.Text = "";
hrs.Value = "";
TextArea1.Value = "";
}
I presume the difference will only be in this line:hookUp = new SqlConnection("Server=localhost\\SqlExpress;Database=test4;" + "Integrated Security=True");