i am trying to insert records into SQL database ..........here is the code snippet
I receive the System.Data.sql client..... Exception
Code:
I receive the System.Data.sql client..... Exception
Code:
Code:
public void setData(CustInfo c)
{
CQuery cq = new CQuery();
ExecuteQuery1(CQuery.custQuery,c);
}
public void ExecuteQuery1(string query,CustInfo c)
{
try
{
string conn = "Persist Security Info =false;Server=intel/sqlexpress;Initial Catalog = Customer;Integrated Security = true";
using (SqlConnection sqlcon = new SqlConnection(conn))
{
using (SqlCommand cmd = new SqlCommand(query, sqlcon))
{
cmd.Parameters.Add(new SqlParameter(@Firstname, c.Firstname));
cmd.Parameters.Add(new SqlParameter(@Email, c.Email));
sqlcon.Open();
cmd.ExecuteNonQuery();
}
}
}
catch (SqlException se)
{
Console.WriteLine(se.ToString());
}
}
}
}
Comment