Skip to content

INSERT,UPDATE on Attached SQL Database File not working.

Joshy Raj

Asked May 15, 2008, 9:46 PM EDT2 answers
Share
LinkedInX
Hi Friends,

I am facing a very bad problem.I have added an SQL Database using VS 2005>>Add New Item>>Sql Database.The problem I am facing is not able to execute an INSERT or UPDATE.But the thing is that just after inserting and viewing the contents of the same table in the same event,the inserted record is displaying.But if I close the application and look into table manually I couldn't see the newly entered record.

ExecuteNonQuery() is working and no exception is thrown.Please Help.Seems like some weird is happening.I dont have an SQL Server installed.I am using VS 2005 only to develop a database application.

Thanks in advance.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Rangga Praduwiratna
    0
    Hello,

    Have you used binding source and table adapter to make your database update synchronously when data is inserted or updated from the forms?
    0
  • 0
    C#
    If you are using Stored Procedures to do the update and insert MAKE certain that your user has permissions to execute the proc
    Also hope this helps
    public static int ExecuteCommand(ConnectionStringSettings ConnectionString, string SQLString)
    {
    int _Count;
    connection = new SqlConnection(ConnectionString.ConnectionString);
    command = new SqlCommand();
    command.Connection = connection;
    command.CommandText = SQLString;
    command.CommandTimeout = 0;
    connection.Open();
    _Count = command.ExecuteNonQuery();
    connection.Close();
    connection.Dispose();
    connection = null;
    command.Dispose();
    command = null;
    return _Count;
    }
    0