System.Data.Odbc.OdbcException

A

Allen Davis

I have a little console app that I wrote in June using Visual Studio .NET to
dump some data from an AS/400 into a CSV file. I've come back to this
application today to make some additions and now, without changing anything
at all in the application since June, it no longer works.

When the application gets to this point...

Sub WriteParts()

Dim objConn As New Odbc.OdbcConnection("DSN=FOO;UID=BAR;PWD=BEE")

Dim objCmd As New Odbc.OdbcCommand("SELECT * FROM DATAFILE", objConn)

objConn.Open()

Dim objReader As Odbc.OdbcDataReader

objReader = objCmd.ExecuteReader

....it stops with the following error.

An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in
system.data.dll

Additional information: System error.

My reading tells me this is the result of an error generated by the server.
But the very same application runs as expected on other computers where it's
been running for months. So what could I have changed on my Windows XP
computer to cause the ODBC driver to foul up?
 
K

Kevin Yu [MSFT]

Hi Allen,

The exception is generally thrown by the server. You can try to check the
following:

1. Step into the code to see which line is the exception thrown.

2. Try to check if the connection is good. To test the connection, you can
create a text file and rename it with the extention ".udl" (For example,
test.udl). Double click it, and follow the wizard to create an ODBC
connection. Click the "Test Connection" button on the connection tab. If
the connection is good, a "Test connection succeeded" dialog box will pop
up.

3. Try to remove and re-create the System DSN on your ODBC Data Source in
Administrative Tools to see if the server is good. BTW, what's the database
system are you using?

HTH

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Allen Davis" <[email protected]>
| Subject: System.Data.Odbc.OdbcException
| Date: Wed, 22 Oct 2003 14:19:19 -0500
| Lines: 32
| Organization: Flex-N-Gate
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: fngfirewall.flex-n-gate.com 12.109.67.2
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:64329
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I have a little console app that I wrote in June using Visual Studio .NET
to
| dump some data from an AS/400 into a CSV file. I've come back to this
| application today to make some additions and now, without changing
anything
| at all in the application since June, it no longer works.
|
| When the application gets to this point...
|
| Sub WriteParts()
|
| Dim objConn As New Odbc.OdbcConnection("DSN=FOO;UID=BAR;PWD=BEE")
|
| Dim objCmd As New Odbc.OdbcCommand("SELECT * FROM DATAFILE", objConn)
|
| objConn.Open()
|
| Dim objReader As Odbc.OdbcDataReader
|
| objReader = objCmd.ExecuteReader
|
| ...it stops with the following error.
|
| An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred
in
| system.data.dll
|
| Additional information: System error.
|
| My reading tells me this is the result of an error generated by the
server.
| But the very same application runs as expected on other computers where
it's
| been running for months. So what could I have changed on my Windows XP
| computer to cause the ODBC driver to foul up?
|
|
|
 
A

Allen Davis

I would sure agree that the exception would be thrown by the server if it
weren't for the fact that the compiled app running on other computers with
no differences in the code works as it did originally and as expected but
doesn't run when I hit the button in Visual Studio .NET. So that's why I
think it's something on my computer that's changed; the .NET framework or a
security update or Microsoft patch though I can't for the life of me think
what it would be.

The exception is thrown as soon as it reaches objReader =
objCmd.ExecuteReader

The data base on the AS/400 I'm connecting to I have to assume is DB2. The
program is a proprietary manufacturing business software package that holds
flat data files from which I pull information using SQL queries.

Using the very same ODBC data source I call in the program, I can run a
database query in Excel and get the contents of the datafile just fine.
That's why I'm stumped.
 
K

Kevin Yu [MSFT]

Hi Allen,

Since the objConn.Open() can be executed successfully, I think the ODBC
connection is good. There might be some thing wrong with the query in your
Odbc command. Would you please check if the table or view named DATAFILE
exists in the database? This might cause a server error, and will return
the information you got. You can run your query in some client tools which
enable you to execute query in DB2 (Just like Query Analyzer in SQL Server).

If the problem still cannot be resolved, please feel free to reply to the
post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Allen Davis" <[email protected]>
| References: <#[email protected]>
<[email protected]>
| Subject: Re: System.Data.Odbc.OdbcException
| Date: Thu, 23 Oct 2003 16:49:54 -0500
| Lines: 107
| Organization: Flex-N-Gate
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#f0aZ#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: fngfirewall.flex-n-gate.com 12.109.67.2
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:64448
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I would sure agree that the exception would be thrown by the server if it
| weren't for the fact that the compiled app running on other computers with
| no differences in the code works as it did originally and as expected but
| doesn't run when I hit the button in Visual Studio .NET. So that's why I
| think it's something on my computer that's changed; the .NET framework or
a
| security update or Microsoft patch though I can't for the life of me think
| what it would be.
|
| The exception is thrown as soon as it reaches objReader =
| objCmd.ExecuteReader
|
| The data base on the AS/400 I'm connecting to I have to assume is DB2. The
| program is a proprietary manufacturing business software package that
holds
| flat data files from which I pull information using SQL queries.
|
| Using the very same ODBC data source I call in the program, I can run a
| database query in Excel and get the contents of the datafile just fine.
| That's why I'm stumped.
|
| | > Hi Allen,
| >
| > The exception is generally thrown by the server. You can try to check
the
| > following:
| >
| > 1. Step into the code to see which line is the exception thrown.
| >
| > 2. Try to check if the connection is good. To test the connection, you
can
| > create a text file and rename it with the extention ".udl" (For example,
| > test.udl). Double click it, and follow the wizard to create an ODBC
| > connection. Click the "Test Connection" button on the connection tab. If
| > the connection is good, a "Test connection succeeded" dialog box will
pop
| > up.
| >
| > 3. Try to remove and re-create the System DSN on your ODBC Data Source
in
| > Administrative Tools to see if the server is good. BTW, what's the
| database
| > system are you using?
| >
| > HTH
| >
| > Kevin Yu
| > =======
| > "This posting is provided "AS IS" with no warranties, and confers no
| > rights."
| >
| > --------------------
| > | From: "Allen Davis" <[email protected]>
| > | Subject: System.Data.Odbc.OdbcException
| > | Date: Wed, 22 Oct 2003 14:19:19 -0500
| > | Lines: 32
| > | Organization: Flex-N-Gate
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.adonet
| > | NNTP-Posting-Host: fngfirewall.flex-n-gate.com 12.109.67.2
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.adonet:64329
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| > |
| > | I have a little console app that I wrote in June using Visual Studio
| .NET
| > to
| > | dump some data from an AS/400 into a CSV file. I've come back to this
| > | application today to make some additions and now, without changing
| > anything
| > | at all in the application since June, it no longer works.
| > |
| > | When the application gets to this point...
| > |
| > | Sub WriteParts()
| > |
| > | Dim objConn As New Odbc.OdbcConnection("DSN=FOO;UID=BAR;PWD=BEE")
| > |
| > | Dim objCmd As New Odbc.OdbcCommand("SELECT * FROM DATAFILE", objConn)
| > |
| > | objConn.Open()
| > |
| > | Dim objReader As Odbc.OdbcDataReader
| > |
| > | objReader = objCmd.ExecuteReader
| > |
| > | ...it stops with the following error.
| > |
| > | An unhandled exception of type 'System.Data.Odbc.OdbcException'
occurred
| > in
| > | system.data.dll
| > |
| > | Additional information: System error.
| > |
| > | My reading tells me this is the result of an error generated by the
| > server.
| > | But the very same application runs as expected on other computers
where
| > it's
| > | been running for months. So what could I have changed on my Windows XP
| > | computer to cause the ODBC driver to foul up?
| > |
| > |
| > |
| >
|
|
|
 
D

Don

Allen said:
I have a little console app that I wrote in June using Visual Studio .NET to
dump some data from an AS/400 into a CSV file. I've come back to this
application today to make some additions and now, without changing anything
at all in the application since June, it no longer works.

When the application gets to this point...

Sub WriteParts()

Dim objConn As New Odbc.OdbcConnection("DSN=FOO;UID=BAR;PWD=BEE")

Dim objCmd As New Odbc.OdbcCommand("SELECT * FROM DATAFILE", objConn)

objConn.Open()

Dim objReader As Odbc.OdbcDataReader

objReader = objCmd.ExecuteReader

...it stops with the following error.

An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in
system.data.dll

Additional information: System error.

My reading tells me this is the result of an error generated by the server.
But the very same application runs as expected on other computers where it's
been running for months. So what could I have changed on my Windows XP
computer to cause the ODBC driver to foul up?


Have you tried enabling ODBC Trace?

I would put a break on the offending line, jump over to the ODBC
Configuration panel and hit the Start Trace button, wait for it to
die, stop tracing and examine the trace log for clues.
 
A

Allen Davis

Further testing reveals that, among several different versions of the ODBC
driver for windows included in both IBM's Client Access Express (V5R1) and
iSeries Access for Windows (V5R2), some fail in the way I've described and
some (two so far) work as expected. We're talking to IBM support now to try
and get to the bottom of this and I'll keep this thread updated with
whatever we find out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top