Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 2nd, 2003, 04:06 AM
aspuser25 aspuser25 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 aspuser25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Question a sample ... connection

i can use asp with access... connectivity is not a problem. i now have to use VB with Access...

can anyone give me a very simple code of linking string thats used for linking vb with access ... i simply want to test hte connectivity.

like i have created a table by the name test.
test...
id 100
name ABC

my form has simple textbox with a button. and on click to button i shud get 'ABC' in textbox?
the query is : select name from test where id = '100'

i just need a sample code to know how to write the connect string using VB with access

that wud be a great help....thanks in advance.

Reply With Quote
  #2  
Old September 2nd, 2003, 08:03 AM
zak2zak zak2zak is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Singapore
Posts: 34 zak2zak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via Yahoo to zak2zak
Lightbulb May i comment

May be this helps...
U Must Referrence u'r project to ADO object library.!
Code:
Dim db_file As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

    ' Get the data.
    db_file = App.Path
    If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
    db_file = db_file & "TheDatabase.mdb"

    ' Open a connection.
    Set conn = New ADODB.Connection
    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & db_file & ";" & "Persist Security Info=False"
    conn.Open

    ' Open the Recordset.
    Set rs = conn.Execute("SELECT name FROM Test WHERE id = '100'", , adCmdText)
    If Not rs.EOF OR rs.BOF then
    rs.MoveFirst
    Text1.Text = rs![name]
    End If
    
    rs.Close
    conn.Close
    Set rs = Nothing
    Set conn = Nothing
__________________
I May Have Misinterpret U'r Post
Correct Me If I Am Wrong......//
Enjoy Coding..........................///

zak2zak

Reply With Quote
  #3  
Old September 2nd, 2003, 09:09 AM
aspuser25 aspuser25 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 aspuser25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thumbs up

hey thanks i wanted something similar to it..
thanks buddy!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > a sample ... connection


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway