[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Error Reading from a Postgres Database

Steve R

7/31/2002 5:02:00 PM

I run the following code and keep getting the following error:
System.ArgumentNullException: Value cannot be null. Parameter name:
dataTable

I can connect to the database and step through records, but any effort to
grab actual data results in this error. I have tried several methods,
including DataReaders, DataTables, and DataGrids.

Thanks,
Steve

Dim oConnection As Microsoft.Data.Odbc.OdbcConnection

Dim oDataTable As DataTable

Dim drDataRow As DataRow

Dim odbcReader As OdbcDataReader

Dim cmdCommand As OdbcCommand

Dim oAdapter As OdbcDataAdapter

oConnection = New OdbcConnection()

oConnection.ConnectionString =
"ODBC;DSN=PostgreSQL;Driver={PostgreSQL};SERVER=MyServer;DATABASE=mydb;UID=m
yuserid;PWD=mypassword"

oConnection.Open()

cmdCommand = oConnection.CreateCommand()

cmdCommand.CommandText = "SELECT countryname, countryid FROM countries"

oAdapter = New OdbcDataAdapter(cmdCommand)

oAdapter.Fill(oDataTable)



1 Answer

Steve R

8/1/2002 12:11:00 AM

0

OK, my bad. I downloaded the lastest postgreSQL ODBC drivers from
http://odbc.postgresql.org/ftpsite/odbc/ver...
and this fixed the problem.


"Steve R" <slraymond@hotmail.com> wrote in message
news:uHxR2MKOCHA.2444@tkmsftngp13...
> I run the following code and keep getting the following error:
> System.ArgumentNullException: Value cannot be null. Parameter name:
> dataTable
>
> I can connect to the database and step through records, but any effort to
> grab actual data results in this error. I have tried several methods,
> including DataReaders, DataTables, and DataGrids.
>
> Thanks,
> Steve
>
> Dim oConnection As Microsoft.Data.Odbc.OdbcConnection
>
> Dim oDataTable As DataTable
>
> Dim drDataRow As DataRow
>
> Dim odbcReader As OdbcDataReader
>
> Dim cmdCommand As OdbcCommand
>
> Dim oAdapter As OdbcDataAdapter
>
> oConnection = New OdbcConnection()
>
> oConnection.ConnectionString =
>
"ODBC;DSN=PostgreSQL;Driver={PostgreSQL};SERVER=MyServer;DATABASE=mydb;UID=m
> yuserid;PWD=mypassword"
>
> oConnection.Open()
>
> cmdCommand = oConnection.CreateCommand()
>
> cmdCommand.CommandText = "SELECT countryname, countryid FROM countries"
>
> oAdapter = New OdbcDataAdapter(cmdCommand)
>
> oAdapter.Fill(oDataTable)
>
>
>