Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Visual Studio 2003 and DBISAM 3.30 ODBC query problem
Fri, Mar 3 2006 9:27 AMPermanent Link

Stu Brown
Hi,

I'm attempting to get DBISAM 3.30 ODBC working with Visual Studio 2003.NET.  I'm very new to .NET so I may ask dumb questions.

I believe I have a working connection to my database 'C:\IPISDATA', but I'm trying to use a query to check the connection, to try and get some sort of output.  I get the
following error when the function is run.

"An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in system.data.dll
Additional information: System error."


The 'button1_Click' function works (see code below).

Neither the 'InsertRow' function or the 'ReadMyData' function work.  What am I missing?

Also what is the best (and simplest) component or way to view a tables data, i.e. like a C++ Builder StringGrid?

Thanks for your help in advance.


Code:

private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
{
  String* myConnString = S"DRIVER={DBISAM 3 ODBC Driver};TablePassword1=
[leftout];ConnectionType=local;CatalogName=C:\IPISDATA;ReadOnly=False;ForceBufferFlush=True;StrictChangeDetection=False;LockRetryCount=15;LockWaitTime=10
0;";
      
  OdbcConnection* myConnection = new OdbcConnection(myConnString);
  myConnection->Open();
  MessageBox::Show(String::Concat(S"ServerVersion: ", myConnection->ServerVersion, S"\nDataSource: ", myConnection->DataSource, S"\nDatabase: ",   
myConnection->Database));
  myConnection->Close();

  InsertRow(myConnString);
  ReadMyData(myConnString);
};
   
public: void InsertRow(String* myConnString)
{
  // If the connection string is null, use a default.
  if (myConnString->Equals(S""))
  {
     String* myConnString = S"DRIVER={DBISAM 3 ODBC Driver};TablePassword1=
[leftout];ConnectionType=local;CatalogName=C:\IPISDATA;ReadOnly=False;ForceBufferFlush=True;StrictChangeDetection=False;LockRetryCount=15;LockWaitTime=10
0;";
  }
  OdbcConnection* myConnection = new OdbcConnection(myConnString);
  String* myInsertQuery = S"INSERT INTO vat (VAT_ID, VAT_RATE) Values(3, 10)";
  OdbcCommand* myOdbcCommand = new OdbcCommand(myInsertQuery);
  myOdbcCommand->Connection = myConnection;
  myConnection->Open();
  myOdbcCommand->ExecuteNonQuery();
  myOdbcCommand->Connection->Close();
  myConnection->Close();
}; // InsertRow

public: void ReadMyData(String* myConnString)
{
  String* mySelectQuery = S"SELECT * FROM VAT";
  OdbcConnection* myConnection = new OdbcConnection(myConnString);
  OdbcCommand* myCommand = new OdbcCommand(mySelectQuery, myConnection);
  myConnection->Open();
  OdbcDataReader* myReader = myCommand->ExecuteReader();

  try
  {
     while (myReader->Read())
     {
        Console::WriteLine("(0){1}", myReader->GetString(0), myReader->GetString(1));
     }
  }
  catch(Exception* e)
  {
     Console::WriteLine("An error occurred: '{0}'", e);
  }

  // always call Close when done with connection.
  myReader->Close();
  // always call Close when done with connection.
  myConnection->Close();
}; // ReadMyData

Fri, Mar 3 2006 9:38 AMPermanent Link

Michael Baytalsky

May I suggest public.odbc group. See topmost posts there.

2Tim: is it time to create DotNet group? Wink

Regards,
Michael

Stu Brown wrote:
> Hi,
>
> I'm attempting to get DBISAM 3.30 ODBC working with Visual Studio 2003.NET.  I'm very new to .NET so I may ask dumb questions.
>
> I believe I have a working connection to my database 'C:\IPISDATA', but I'm trying to use a query to check the connection, to try and get some sort of output.  I get the
> following error when the function is run.
>
> "An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in system.data.dll
> Additional information: System error."
>
>
> The 'button1_Click' function works (see code below).
>
> Neither the 'InsertRow' function or the 'ReadMyData' function work.  What am I missing?
>
> Also what is the best (and simplest) component or way to view a tables data, i.e. like a C++ Builder StringGrid?
>
> Thanks for your help in advance.
>
>
> Code:
>
> private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
> {
>    String* myConnString = S"DRIVER={DBISAM 3 ODBC Driver};TablePassword1=
> [leftout];ConnectionType=local;CatalogName=C:\IPISDATA;ReadOnly=False;ForceBufferFlush=True;StrictChangeDetection=False;LockRetryCount=15;LockWaitTime=10
> 0;";
>        
>    OdbcConnection* myConnection = new OdbcConnection(myConnString);
>    myConnection->Open();
>    MessageBox::Show(String::Concat(S"ServerVersion: ", myConnection->ServerVersion, S"\nDataSource: ", myConnection->DataSource, S"\nDatabase: ",   
> myConnection->Database));
>    myConnection->Close();
>
>    InsertRow(myConnString);
>    ReadMyData(myConnString);
> };
>    
> public: void InsertRow(String* myConnString)
> {
>    // If the connection string is null, use a default.
>    if (myConnString->Equals(S""))
>    {
>       String* myConnString = S"DRIVER={DBISAM 3 ODBC Driver};TablePassword1=
> [leftout];ConnectionType=local;CatalogName=C:\IPISDATA;ReadOnly=False;ForceBufferFlush=True;StrictChangeDetection=False;LockRetryCount=15;LockWaitTime=10
> 0;";
>    }
>    OdbcConnection* myConnection = new OdbcConnection(myConnString);
>    String* myInsertQuery = S"INSERT INTO vat (VAT_ID, VAT_RATE) Values(3, 10)";
>    OdbcCommand* myOdbcCommand = new OdbcCommand(myInsertQuery);
>    myOdbcCommand->Connection = myConnection;
>    myConnection->Open();
>    myOdbcCommand->ExecuteNonQuery();
>    myOdbcCommand->Connection->Close();
>    myConnection->Close();
> }; // InsertRow
>
> public: void ReadMyData(String* myConnString)
> {
>    String* mySelectQuery = S"SELECT * FROM VAT";
>    OdbcConnection* myConnection = new OdbcConnection(myConnString);
>    OdbcCommand* myCommand = new OdbcCommand(mySelectQuery, myConnection);
>    myConnection->Open();
>    OdbcDataReader* myReader = myCommand->ExecuteReader();
>
>    try
>    {
>       while (myReader->Read())
>       {
>          Console::WriteLine("(0){1}", myReader->GetString(0), myReader->GetString(1));
>       }
>    }
>    catch(Exception* e)
>    {
>       Console::WriteLine("An error occurred: '{0}'", e);
>    }
>
>    // always call Close when done with connection.
>    myReader->Close();
>    // always call Close when done with connection.
>    myConnection->Close();
> }; // ReadMyData
>
>
Fri, Mar 3 2006 11:10 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< 2Tim: is it time to create DotNet group? Wink >>

It's getting there.  If I can get some uninterruped stretches here, then I
can finish this damn thing up. Wink

--
Tim Young
Elevate Software
www.elevatesoft.com

Fri, Mar 3 2006 11:12 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Stu,
<< I get the following error when the function is run.

"An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred
in system.data.dll
Additional information: System error."

The 'button1_Click' function works (see code below).

Neither the 'InsertRow' function or the 'ReadMyData' function work.  What am
I missing? >>

Where does the InsertRow error occur ?  During the ExecuteNonQuery call ?
Also, is the exception the same for both ?  Finally, are you using the trial
version or the normal full version ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Mar 6 2006 4:28 AMPermanent Link

Stu Brown
Hi Tim,

The errors occur on the following lines of the 2 functions when each function is run seperatly run (i.e. the other function is commented out).

InsertRow fails on this line:
myOdbcCommand->ExecuteNonQuery();

ReadMyData fails on this line:
OdbcDataReader* myReader = myCommand->ExecuteReader();

thanks


"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

Stu,
<< I get the following error when the function is run.

"An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred
in system.data.dll
Additional information: System error."

The 'button1_Click' function works (see code below).

Neither the 'InsertRow' function or the 'ReadMyData' function work.  What am
I missing? >>

Where does the InsertRow error occur ?  During the ExecuteNonQuery call ?
Also, is the exception the same for both ?  Finally, are you using the trial
version or the normal full version ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Mar 6 2006 11:49 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Stu,

<< The errors occur on the following lines of the 2 functions when each
function is run seperatly run (i.e. the other function is commented out). >>

Do you know how to turn on ODBC logging ?  I need to see an ODBC log to
determine what's going on.  There are brief instructions on how to do so
here:

http://www.elevatesoft.com/scripts/newsgrp.dll?action=openmsg&group=14&msg=1126&page=1#msg1126

--
Tim Young
Elevate Software
www.elevatesoft.com

Image