Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ExecuteReader: Connection property has not been initialized.

Status
Not open for further replies.

dogynite

Programmer
Mar 7, 2005
1
IL
Hi All!
I have recently downloaded and installed MySql data base.
I'm working on windows xp pro; visual studio 2003 .net; c#
In addition, I've downloaded and installed the MySql Administrator app with which I have created a schema and
a table in MysQl.
I Can not manage to connect the odbc classes with MySql!!!!!
the connection string I wrote is:
protected string strConnect = "DRIVER={MySQL ODBC 3.51 Driver};Data C:\\MySQL\\MySQL Server 4.1\\data\mysql\\time_zone.frm;SERVER=localhost;DATABASE=mysql;UID=root;PASSWORD=1;OPTION=3";
Th way I'm trying to connect and get the data is:
try
{
odbcConn = new OdbcConnection();
odbcConn.ConnectionString = strConnect;


string SQL = "SELECT * FROM mysql";
odbcCommand = new OdbcCommand(SQL);
odbcConn.Open();
odbcDR = odbcCommand.ExecuteReader();
while( odbcDR.Read() )
{
richTextBox1.Text = "LangID: " + odbcDR["GroupId"] + " , ";
richTextBox1.Text = "Desc :" + odbcDR["Description"];
}

odbcDR.Close();
odbcConn.Close();

}
catch(System.Exception err)
{
richTextBox1.Text = err.Message;
}
In the data source which are the files (exrensions) to connect, refering MySql?? (.frm,.myd)
what are the differences??
And most of all WHAT am I DOING WRONG??
Thax deeply!
 
MySQL is a database server, like SQL Server, not a database system, like Access. At no time will your code ever touch the actual database files on the filesystem. Instead, your application will connect to the server, pass queries to the server, and optionally receive data back. The server will handle manipulation of the files.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
here's a valid connection string for MySQL:

MyConString = String.Format("DRIVER={{MySQL ODBC 3.51 Driver}};" +
"SERVER={0};" +
"DATABASE={1};" +
"UID={2};" +
"PASSWORD={3};" +
"OPTION=3", srvName, dbName, u, p);



------------------------
dev at viewmoresoft.com
tools for your database
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top