public static string Insert_Data(int code, string userName, string englishName, string country)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("Insert into hazem (Code,UserName,EnglishName) values (@code,@userName,@englishName)", conn);
SqlCommand cmd2 = new SqlCommand("Insert into country (CountryName) values (@country)", conn);
cmd2.CommandType = CommandType.Text;
cmd2.Parameters.AddWithValue("@country", country);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@code", code);
cmd.Parameters.AddWithValue("@userName", userName);
cmd.Parameters.AddWithValue("@englishName", englishName);
cmd.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
conn.Close();
return "Success";
}
catch (Exception ex)
{
return "failure";
}
}
What's the error in this program?
Inscription à :
Publier les commentaires (Atom)