System.InvalidOperationException: Connection must be valid and open.
From: Alejandro Penate-Diaz (alejandro_at_apenate.com)
Date: 12/18/04
- Next message: Alejandro Penate-Diaz: "Re: System.InvalidOperationException: Connection must be valid and open."
- Previous message: ronaldlee: "Collection Read Only ERROR, help"
- Next in thread: Alejandro Penate-Diaz: "Re: System.InvalidOperationException: Connection must be valid and open."
- Reply: Alejandro Penate-Diaz: "Re: System.InvalidOperationException: Connection must be valid and open."
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 17 Dec 2004 22:06:32 -0500
Hi.
I am using this function tu execute updates to a MySql database from a sql
string, but I am getting a System.InvalidOperationException: Connection
must be valid and open.
Database queries work fine, but I cant update the source. Am I missing
something?
Thanks, Alejandro.
public static bool updateSource(string sql)
{
MySqlConnection conn = new MySqlConnection(myConnectionString);
MySqlCommand command = new MySqlCommand(sql,conn);
command.CommandType = CommandType.Text;
try
{
command.ExecuteNonQuery();
return true;
}
catch (Exception)
{return false;}
finally
{
conn.Close();
}
- Next message: Alejandro Penate-Diaz: "Re: System.InvalidOperationException: Connection must be valid and open."
- Previous message: ronaldlee: "Collection Read Only ERROR, help"
- Next in thread: Alejandro Penate-Diaz: "Re: System.InvalidOperationException: Connection must be valid and open."
- Reply: Alejandro Penate-Diaz: "Re: System.InvalidOperationException: Connection must be valid and open."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|