Jump to content
Sign in to follow this  

[Resolvido] ligaçao via odbc

Recommended Posts


tou me a tentar ligar num odbc criado no meu computador onde se liga a base de dados, tou com o seguinte código so que não me retorna nada. o que tou a fazer de errado??

Dim constring As String = "Dsn=ODBCNAME; provider=System.Data.Odbc"
Dim cn As New OdbcConnection
Dim ds As New DataSet
Dim dt As New DataTable
Dim adap As New OdbcDataAdapter("select * from item", cn)
adap.Fill(ds, "item")
dt = ds.Tables(0)
DataGridView1.DataSource = ds.Tables("item")

Edited by thoga31
Tags code + GeSHi

Share this post

Link to post
Share on other sites

aqui fica a solução do meu problema para aqueles que procuram tambem

Dim conn As OdbcConnection
    Dim connectionString As String
    Dim sql As String
    connectionString = "DSN=Nome;UID=sa;Pwd=pass;"
    conn = New OdbcConnection(connectionString)
    'Reading from DB to DataSet and displaying by data grid 
    Dim ds As New DataSet()
    Dim adap As New OdbcDataAdapter("select * from customer", conn)
    adap.Fill(ds, "customer")
	 DataGridView1.DataSource = ds.Tables("customer")

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.