[lnkForumImage]
TotalShareware - Download Free Software

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


 

Karyono

8/26/2002 10:32:00 AM

Can help me with this code what wrong ?


Dim con As New Microsoft.Data.Odbc.OdbcConnection()
Dim cmd As New Microsoft.Data.Odbc.OdbcCommand()

con.ConnectionString = "DSN=mysqldsn"

Strsql = "Select * from user"

Dim Ds As New DataSet()

Dim objDA As New Microsoft.Data.Odbc.OdbcDataAdapter()

objDA = New Microsoft.Data.Odbc.OdbcDataAdapter(Strsql, con)

objDA.Fill(Ds, "test")

DataGrid1.DataSource = Ds

DataGrid1.Refresh()

con.Close()

con = Nothing

when i try to fill from data adapter appear error like bellow

An unhandled exception of type
'Microsoft.Data.Odbc.OdbcException' occurred in microsoft.data.odbc.dll

Additional information: System error.


2 Answers

Bob Beauchemin

8/26/2002 6:17:00 PM

0

You don't need to close the connection when using a DataAdapter because, if
you don't open the connection before calling Fill, the connection is
automatically close at the end of Fill.

If this doesn't fix the problem, I'd recommend running the code in a
debugger and seeing the exact statement where the error occurs.

Bob Beauchemin
http://staff.develo...


"Karyono" <Karyono@myoh.com> wrote in message
news:#QuDfjNTCHA.3904@tkmsftngp12...
> Can help me with this code what wrong ?
>
>
> Dim con As New Microsoft.Data.Odbc.OdbcConnection()
> Dim cmd As New Microsoft.Data.Odbc.OdbcCommand()
>
> con.ConnectionString = "DSN=mysqldsn"
>
> Strsql = "Select * from user"
>
> Dim Ds As New DataSet()
>
> Dim objDA As New Microsoft.Data.Odbc.OdbcDataAdapter()
>
> objDA = New Microsoft.Data.Odbc.OdbcDataAdapter(Strsql, con)
>
> objDA.Fill(Ds, "test")
>
> DataGrid1.DataSource = Ds
>
> DataGrid1.Refresh()
>
> con.Close()
>
> con = Nothing
>
> when i try to fill from data adapter appear error like bellow
>
> An unhandled exception of type
> 'Microsoft.Data.Odbc.OdbcException' occurred in microsoft.data.odbc.dll
>
> Additional information: System error.
>
>


(Hussein Abuthuraya(MSFT))

8/26/2002 11:23:00 PM

0

Couple of suggestions here:

- Have you had chance to test the DSN from with in the ODBC Administrator?
- Add con.Open before the dataadapter.FIll to make sure that openining the connection is fine.
- Make sure that user table exists in you database
- Wrap the DataAdapter.Fill within a Try ... Catch... Block and see if the error message maybe more meaningful.
- Try different table fro mthe same database.

Is this an Access Database?
Are you running the code from Windows or Web form?

I hope this help!


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

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

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....