protected void btnSubmit_Click(object sender, EventArgs e) { try { string connStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\MyProjects\LeaveMgt\LeaveMgt\App_Data\LeaveMgt.mdf;Integrated Security=True;User Instance=True"; SqlConnection dbCon = new SqlConnection(connStr); SqlCommand comm = new SqlCommand(); dbCon.Open(); comm.CommandType = CommandType.Text; comm.Connection = dbCon; comm.CommandText = ("INSERT INTO LeaveCover VALUES('" + txtEmpNo.Text + "','" + txtEmpName.Text + "','" + txtCoverUp.Text + "','" + txtActOff.Text + "', '" + txtDate.Text + "','" + txtLevAdd.Text + "','" + ddlApprove.Text + "', '" + ddlNor.Text + "','" + ddlNotLev.Text + "')"); comm.ExecuteNonQuery(); dbCon.Close(); lblMessage.Text = "Ok"; } catch { lblMessage.Text = "Bad"; } When I click the submit button it always trig the cath{} but I cannot find the error! My Database is at the following location and the connection string is as the following. DB@ <pre lang="c#">D:\MyProjects\LeaveMgt\LeaveMgt\App_Data\LeaveMgt.mdf
string connStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\MyProjects\LeaveMgt\LeaveMgt\App_Data\LeaveMgt.mdf;Integrated Security=True;User Instance=True";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)