hey guys..i am trying to add records to my db...i created stored procedure and it works...but although it can add the datas it show message box and failed because of the if situation i think..but i didnt understand where is my mistake
try
{
con = new SqlConnection("data source=Erdinc;initial catalog=deneme;integrated security=true");
cmd = new SqlCommand("sp_TablolaraEkle", con);
con.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@marka_ad", System.Data.SqlDbType.NVarChar, 50).Value = textBox1.Text;
cmd.Parameters.Add("@model_ad", System.Data.SqlDbType.NVarChar, 50).Value = textBox2.Text;
int rows = cmd.ExecuteNonQuery();
if (rows == 1)
MessageBox.Show("Succeed", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show("Failed", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
con.Close();
}
Loading

Rakesh Jha85 reputationPosted Oct 5, 2010, 5:54 AM EDT
con = new SqlConnection("data source=Erdinc;initial catalog=deneme;integrated security=true");
i put my below connection string
con = new SqlConnection("server=servername; database=dbname; user id=username; password=password");
Erdinc Kolukisa109 reputationPosted Oct 5, 2010, 6:42 AM EDT