user1311083
user1311083

Reputation: 1

insert query is giving no error but is not inserting in the database

I have a insert query which i m using to insert data into SQL Server DB 2008 using c#.net code. the query does not give any error but also does not insert data into DB Following is the code :-

string strcon = connection();

if (con.State == ConnectionState.Closed)
{
    con.ConnectionString = strcon;
    con.Open();
    strquery = query + " values( '"+ cheqval +"' , '" +
        dtval.ToShortDateString() +"' , '"+ amtval +"','"+ conameval + "')";
    SqlCommand cmd =  new SqlCommand(strquery, con);
    i = cmd.ExecuteNonQuery();
    con.Close();
}

my insert query is forming correctly but is not inserting data into the DB. What shud i do .... please help .... i also tried the parameterised query but even that does not work :((

Upvotes: 0

Views: 4458

Answers (1)

HLGEM
HLGEM

Reputation: 96552

One thing to check is to see if the table has a trigger. An instead of trigger could be overruling your insert. The comments about checking to see if you are hitting the inside of the IF or that one value being null making the code workout incorrectly are also things to check.

Upvotes: 1

Related Questions