Help Me With Reading From Access Database

ACCESS ADO

New member
Joined
May 18, 2006
Messages
3
Hi all,
I have a very strange problem with accessing and reading from my access database.
my .mdb file is password protected, the pass is "12345".
ok, the code works fine when I want to read data from Table "SC"
but when I want to read the data from Table "Groups" I cannot!!!
you simply can replace this code with the one is my form_load event:
and will see that it wont work anymore!
pleassssseeeeeeee help meeeeeee! :(

Code:
        Dim STrPath = System.IO.Directory.GetCurrentDirectory & "\0.mdb"
        Try
            DB = New OleDbConnection("Provider=microsoft.jet.oledb.4.0; data source=" & STrPath & ";jet oledb:database password=12345")
            Dc = New OleDbCommand("Select * from Groups where GroupName<>null order by name asc")
            DB.Open()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "")
            End
        End Try
        Dc.Connection = DB
        Dim Dr As OleDb.OleDbDataReader = Dc.ExecuteReader
        GroupComboBox.Items.Clear()
        While Dr.Read
            GroupComboBox.Items.Add(Dr("GroupName"))
        End While
        DB.Close()
 

Attachments

Sounds like youre run into a common problem, the name of the table is a reserved word...
Change the name of the table and try again.

HTH
/Kejpa
 
perhaps no, when i change my code to refer to table "Groups", i get this error:
-
No value given for one or more required parameters.
-
Exactly for this line:
-
Dim Dr As OleDb.OleDbDataReader = Dc.ExecuteReader
-
I have changed the Table name, no luck!
please help me:(
 
Sorry,
I was too quick in my assumptions :o
The reason is in your code...
Code:
Dc = New OleDbCommand("Select * from Groups where GroupName<>null order by name asc")
when dealing with null you need to use is and is not like this
Code:
Dc = New OleDbCommand("Select * from Groups where GroupName [i][u]is not[/u][/i] null order by name asc")

HTH
/Kejpa
 
Back
Top