Hi All,
I am trying to insert data into my database, the query is running smooth, that is without any error but the problem is that the data isn't being inserted and table remains empty.
Here is the code i'm using:
[C#]
string sConnectionString = ConfigurationManager.ConnectionStrings["StagingAreaDB.Properties.Settings.StagingAreaDBConnectionString"].ConnectionString;
SqlConnection cSqlConnection = new SqlConnection(sConnectionString);
SqlCommand cSqlCommand = new SqlCommand();
cSqlCommand.CommandText = "insert into CropData(PesticideUsed,PesticideSprayDate, PesticideDosage, CLCV, PlantHeight) Values ('Triazophos' , '11/09/2004' , '459 grams' , '46 Medium' , '46 foot');";
cSqlCommand.CommandType = CommandType.Text;
cSqlCommand.Connection = cSqlConnection;
cSqlConnection.Open();
try
{
cSqlCommand.ExecuteNonQuery();
}
catch(Exception ex)
{
MessageBox.Show(ex.StackTrace.ToString());
}
finally
{
cSqlConnection.Close();
}
Can anybody tell me that where the probelm?
Thanks in advance.
!--removed tag-->
Enter your message below
Sign in or Join us (it's free).