Quantcast
Viewing all articles
Browse latest Browse all 27398

[RESOLVED] trying to connect to a database....

Hello,

I am trying to connect to my database and am using the following code

Code:

Imports System.Data
Public Class Form1
    Dim con As New OleDb.OleDbConnection

    Dim ds As New DataSet

    Dim da As OleDb.OleDbDataAdapter

    Dim sql As String

    Dim MaxRows As Integer

    Dim inc As Integer = -1

  Private Sub TabPage2_Click(sender As System.Object, e As System.EventArgs) Handles TabPage2.Click

        con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Unit2.MDB"

        sql = "Select * From SRuser Where stage = Test"

        con.Open()

        da = New OleDb.OleDbDataAdapter(sql, con)

        da.Fill(ds, "User")

        con.Close()

        cbTestEmp.DataSource = ds.Tables("User")

        cbTestEmp.DisplayMember = ("Uname")

    End Sub

when i run the code nothing appears to happen, I can't see where I have gone wrong.

can anyone spot anything glaringly obvious??

Thanks for your time

Viewing all articles
Browse latest Browse all 27398

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>