I want to insert data using asp.net web application through Sql 2005..
Code:
private void ConnectionDetails()
{
SqlConnection con = new SqlConnection("Data Source=ALIASGAR-EAE104;Initial Catalog=RajaCompany;Integrated Security=True;Database=RajaCompany;user id=sa;password=sql2005");
//con.Open();
//con.ConnectionString = "Data Source=ALIASGAR-EAE104;Initial Catalog=RajaCompany;Integrated Security=True;Database=RajaCompany;user id=sa;password=sql2005";
SqlCommand cmd = new SqlCommand("Insert * INTO Client Details(Client Name, Client Number, Client Email, Purpose, Qutation, Qutation Date, Client Address, Comments, Meeting Date) VALUES ( '" + txtClient.Text + "', '" + txtNumber.Text + "', '" + txtmail.Text + "', '" + txtpurpose.Text + "', '" + txtqutation.Text + "', '" + QutationCal.SelectedDate + "', '" + txtAddress.Text + "', '" + txtComments.Text + "', '" + MeetingCal.SelectedDate + "')", con);
con.Open();
DataSet ds = new DataSet();
cmd.ExecuteNonQuery();
}
//private object mbox(string p)
//{
// throw new Exception("The method or operation is not implemented.");
//}
protected void Button1_Click(object sender, EventArgs e)
{
//ClientDetailDataSource.Insert();
int score = Convert.ToInt32 (Validate());
// if (score < 7)
// {
// error_label.Visible = true;
// }
// else
// {
// error_label.Visible = false;
// Response.Redirect("ClientData.aspx?");
// }
if (score < 7)
{
error_label.Visible = true;
}
else
{
error_label.Visible = false;
SqlDataSource1.Insert();
Response.Redirect("ClientData.aspx?");
}
}
Configuration: Windows XP Firefox 3.0.11