| | |
how to connect my data base in vb.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Aug 2007
Posts: 18
Reputation:
Solved Threads: 0
hi all:
I am a newbie , trying to connect my access to vb.net express edition I wrote the following code:
Imports System.Data
Public Class Form1
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
Dim con As OleDb.OleDbConnection
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0 ; Data Source = "C:\Documents and Settings\shassanzadeh\Desktop\Sara\extra\AddressBook.mdp"
End Sub
End Class
but the compiler gives me error for this line:
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0 ; Data Source = "C:\Documents and and Settings\shassanzadeh\Desktop\Sara\extra\AddressBook.mdp"
the erros says:Character constant must contain exactly one character.
can you guys help me ...
I am a newbie , trying to connect my access to vb.net express edition I wrote the following code:
Imports System.Data
Public Class Form1
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
Dim con As OleDb.OleDbConnection
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0 ; Data Source = "C:\Documents and Settings\shassanzadeh\Desktop\Sara\extra\AddressBook.mdp"
End Sub
End Class
but the compiler gives me error for this line:
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0 ; Data Source = "C:\Documents and and Settings\shassanzadeh\Desktop\Sara\extra\AddressBook.mdp"
the erros says:Character constant must contain exactly one character.
can you guys help me ...
You don't need to surround the database path in quotes inside a connection string. The key/value pairs are all delimited. It should look like this instead.
VB.NET Syntax (Toggle Plain Text)
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\shassanzadeh\Desktop\Sara\extra\AddressBook.mdp"
The truth does not change according to our ability to stomach it.
•
•
Join Date: Aug 2007
Posts: 18
Reputation:
Solved Threads: 0
thanks hamrick
I did that now I have this code :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'seting the data connection
Dim sql As String
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\shassanzadeh\Desktop\Sara\extra\AddressBook.mdp"
'setting the data Adaptor and Data set
con.Open()
Sql = "SELECT * FROM tblContacts"
da = New OleDb.OleDbDataAdapter(Sql, con)
MsgBox("connection open")
con.Close()
MsgBox("connection close")
End Sub
and no syntex error but while I compile it doesnt show any thing and after that I get this error"OleDbException was unhandled "and it poits to a yellow line on con.open()
well according to this link because I am using express edition , I should set my project refrences to System.Xml.dll but here there is no such thing it is only system.xml what do you think I should do?
I did that now I have this code :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'seting the data connection
Dim sql As String
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\shassanzadeh\Desktop\Sara\extra\AddressBook.mdp"
'setting the data Adaptor and Data set
con.Open()
Sql = "SELECT * FROM tblContacts"
da = New OleDb.OleDbDataAdapter(Sql, con)
MsgBox("connection open")
con.Close()
MsgBox("connection close")
End Sub
and no syntex error but while I compile it doesnt show any thing and after that I get this error"OleDbException was unhandled "and it poits to a yellow line on con.open()
well according to this link because I am using express edition , I should set my project refrences to System.Xml.dll but here there is no such thing it is only system.xml what do you think I should do?
•
•
•
•
because I am using express edition , I should set my project refrences to System.Xml.dll but here there is no such thing it is only system.xml
The truth does not change according to our ability to stomach it.
Put it somewhere else without all of the extra nesting, like C:\. Make sure that the extension is right. If this is access, it should be *.mdb, not *.mdp, I think. When it tells you it can't find the file, it can't find the file.
That means the connection string is wrong somehow.
That means the connection string is wrong somehow. The truth does not change according to our ability to stomach it.
Read this article and you can even download a working sample which uses Connection to Access DB through ASP. Click here
![]() |
Similar Threads
- can't binding an autoincrement field of mysql data base from vb.net (VB.NET)
- creating an data base by using VB.net ((important)) (VB.NET)
- data base connection in vb.net (VB.NET)
- conversion of text file into data base file (Visual Basic 4 / 5 / 6)
- decrementing values in data base (ASP)
- Program Problem with a select statement to access Data base (C)
- Need to make program access a data base primary key number entered by user (C)
Other Threads in the VB.NET Forum
- Previous Thread: how to load specific data into a texbox...
- Next Thread: 2-tier softwares
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access arithmetic array assignment basic binary bing box button buttons center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net excel file-dialog firewall folder ftp google hardcopy image images isnumericfuntioncall listview login math memory mobile ms mssqlbackend mysql navigate net networking opacity output peertopeervideostreaming picturebox picturebox1 port print printpreview problemwithinstallation project record reports" save savedialog searchbox serial soap sorting string tcp temp text textbox timer toolbox trim updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





