Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello!

 

Here is my code :

 

Dim myConnection As New OleDb.OleDbConnection

Dim myReader As OleDb.OleDbDataReader

Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=C:\erco\erco.mdb"

myBase = New OleDb.OleDbConnection(myConnectionString)

myBase.Open()

 

Dim myCommand As New OleDb.OleDbCommand

Dim mySelect As String = "SELECT code,name FROM articles WHERE code='1'"

myCommand = New OleDb.OleDbCommand(mySelect, myBase)

myReader = myCommand.ExecuteReader()

 

Dim str As String

While (myReader.Read())

str = myReader("name")

End While

myReader.Close()

  • Leaders
Posted

try this :

   Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
       Dim sConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDb.mdb;"
       Dim Conn As New OleDb.OleDbConnection(sConnString)

       Try
           Dim sCommand As String = "Select * From Table1"

           Conn.Open()
           Dim Command As New OleDb.OleDbCommand(sCommand, Conn)
           Dim reader As OleDb.OleDbDataReader
           reader = Command.ExecuteReader
           Dim x As Integer
           For x = 0 To reader.FieldCount - 1
               MessageBox.Show(reader.GetName(x)) '/// the names of your fields.
           Next
       Catch ex As Exception
           MessageBox.Show(ex.Message)
       Finally
           Conn.Close()
       End Try
   End Sub

it may help.

  • *Experts*
Posted

       Dim str As String
       Dim myReader As OleDbDataReader
       While (myReader.Read())
           If Not IsDBNull(myReader("name")) Then
               str = myReader("name")
           Else
               str = ""

           End If

       End While
       myReader.Close()

 

 

 

Jon

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...