ss_parn
03-07-02, 16:52
| I've managed to get a OBDC connection with .net and mysql but it blows up when I try and do anything. Here is the code . using Microsoft.Data.Odbc; . . private void button1_Click(object sender, System.EventArgs e) { try { string connect = "DSN=TileDSN;"; string command = "select * from sound_lookup"; OdbcConnection con = new OdbcConnection(connect); con.Open(); OdbcDataAdapter dAdpt = new OdbcDataAdapter(command,con); DataSet Data = new DataSet(); dAdpt.Fill(Data,"Sound_Lookup"); con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message +"\n" + ex.Source+ "\n" + ex.ToString()); } } And here is the Exception is throws Object reference not set to an instance of an object. Microsoft.Data.Odbc System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.Common.Odbc32.SQLExecDirectW(IntPtr StatementHandle, String StatementText, Int32 TextLength) at Microsoft.Data.Odbc.OdbcCommand.ExecuteReaderObjec t(CommandBehavior behavior, String method) at Microsoft.Data.Odbc.OdbcCommand.ExecuteReader(Comm andBehavior behavior) at Microsoft.Data.Odbc.OdbcCommand.System.Data.IDbCom mand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) at WindowsApplication2.Form1.button1_Click(Object sender, EventArgs e) in d:\projects\windowsapplication2\form1.cs:line 110 It blows up on the fill statement. Evidently something isn't getting set, but what I have no idea as to what. Thanks Harvey Morris |