Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help on viewing data from acess to vb

Status
Not open for further replies.

alexx123

Programmer
Feb 11, 2009
2
MY
hi, i am a beginner to vb , i am trying to view the data in Microsoft access and displaying the data in one of database columun into a textbox. But i hit a problem i keep getting a error say that "Name adOpenDynamic and adLockOptimisti is not declared".I am using the visual basic 2008 express edition to do all this coding.

The Code :

Dim Conn As ADODB.Connection
Conn = New ADODB.Connection
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Nemo Dive Resort.mdb"


Conn.Open("select * from tables", Conn, adOpenDynamic, adLockOptimisti)
Do While Not Conn.EOF

TextBox3.Text = Conn.Fields(1).Value
Conn.MoveNext()
Loop
 
First thing, you forgot the "c" at the end of adLockOptimistic.

Secondly, make sure you have the following two lines of code at the top of your code file:
Code:
Imports ADODB.LockTypeEnum
Imports ADODB.CursorTypeEnum

Thirdly, I would suggest learning ADO.Net in Visual Basic.Net instead of uzing ADODB. ADO.Net is the preferred data access method in .Net

 
Hmmm... Doesn't it work if you just delete them?

Anyway I've always used an OleDbConnection for opening Microsoft Acces databases and it has always worked smoothly, you could acces it with this type of connection i.e:

Private conn As New OleDbConnection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\DB.mdb;User Id=admin;Password=;"
conn.Open()

Then I believe that by using a OleDbDataReader object you could achieve the same funcionality.
 
thanks u for the advice i will take the advice, do u guys know any good book on this visual basic.net ?.
 
do u guys know any good book on this visual basic.net ?.

Not really. The last VB.Net book I had was for version 1.0, which is far too outdated to suggest. Someone else may know of a more recent book that would be adequate. If not, I would suggest just doing what I normally do -- check out different books on the topic at a bookstore (even if you order it from somewhere else), and browse through it to see if it covers what you need.

For sure, you're going to want to get one that goes in depth in ADO.Net, and either Windows Forms if you're developing for the desktop, or Web Forms if you're developing .Net web applications.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top