Arun Kuamr

Arun Kuamr

  • 2.1k
  • 56
  • 2.5k

odbc connectivity

Apr 14 2016 7:58 AM
Hi All,
 
I went through  code of a project and i observe that a odbc adapter fill dataset sucessfully but connection is closed or only connection string provided.
 
I am confuse how it work , I think connection should be open other wise exception should be throw.
 
Kindly clear my confusion.
Below are the code: -  
 
Dim dbconn As Odbc.OdbcConnection
dbconn = New Odbc.OdbcConnection(connectionstring)
If dbconn.State <> ConnectionState.Open Then
dbconn.Open()
End If
dbconn.Close()
Dim dbAdapter As Odbc.OdbcDataAdapter
dbAdapter = New Odbc.OdbcDataAdapter("select * from studdent where id=5", dbconn)
Dim ds As New DataSet
dbAdapter.Fill(ds)
 

Answers (6)