when i click insert button that i have created on asp.net application all records that i enter automatically gets stored in my employee_tab(table).my code for insert button is as follows:
SqlConnection con = new SqlConnection();
SqlCommand com = new SqlCommand();
com.Connection = con;
con.ConnectionString = (@"add name="constr"; connectionString ="Data Source=localhost;Initial Catalog=master;Integrated Security=True");
int a = Convert.ToInt32(txtEmpId.Text);
string b = (txtEmp_name.Text );
int c = Convert.ToInt32(txtSalary.Text);
string d = (txtCity.Text);
com.CommandText = "INSERT INTO employee_tab(EmpId,Emp_name,Salary,City) values (@a,@b,@c,@d)";
com.Parameters.AddWithValue("@a" , a );
com.Parameters.AddWithValue("@b",b );
com.Parameters.AddWithValue("@c", c );
com.Parameters.AddWithValue("@d",d );
com.Connection.Open();
com.ExecuteNonQuery();
com.Connection.Close();
Also i have created a SP and it is also giving error.i want to do this all with help of SP only.
stored proc is as follows:
create procedure spdatabaseconnectivity
(
@EmpId int,
@Emp_name,
@Salary,
@City)
as
begin
(insert into employee_tab(EmpId,Emp_name,Salary,City)
values (@EmpId,@Emp_name,@Salary,@city))
end
is my connection string is correct?
help me solve this que.my table resides in system database.i think there is a problem with my connection string.the error i am getting when executing c# code is : Only one element allowed per config file and if present must be the first child of the root element.
Thanks.