Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 won't work anymore!

pleassssseeeeeeee help meeeeeee! :(

 

       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()

MyProblem.zip

Posted

Sounds like you're 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

Posted

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:(

Posted

Sorry,

I was too quick in my assumptions :o

The reason is in your 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

Dc = New OleDbCommand("Select * from Groups where GroupName [i][u]is not[/u][/i] null order by name asc")

 

HTH

/Kejpa

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...