|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
hey thanks i wanted something similar to it..
thanks buddy! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > a sample ... connection |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|