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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Access data connection

Status
Not open for further replies.

whateveragain

Programmer
Apr 20, 2009
92
US
I'm using VS 2008, SQL 2008, MS Access 2007 all on Vista OS. I'm trying to connect to an MS Access mdf file as my web site provider doesn't allow SQLExpress. I tried using the gooey data binder to determine the proper coding for the Access.mdf file, but all it gives me is "~/App_Data/whichdata.mdb". The following is the error message I'm receiving and below that is my code. What is wrong with my string? Thanks

Error msg:
[DBNETLIB][ConnectionOpen (Connect()).] SQL Server does not exist or access denied.
Invalid connection string attribute.

My code:
Dim oleconn As New OleDb.OleDbConnection()

oleconn.ConnectionString = "provider=sqloledb;database=~/App_Data/whichdata.mdb;trusted_connection=yes;connection timeout=30"
Try
oleconn.Open()
Catch oleerr As Exception
MsgBox(oleerr.Message)
MsgBox("connection error!")
End Try
If oleconn.State = 1 Then
Msgbox("Welcome to ado.net!")
End If

Dim olecomm As New OleDb.OleDbCommand()
olecomm.Connection = oleconn
olecomm.CommandText = "select count(*) from whichdata where sessionID like session.sessionID"

MsgBox(olecomm.ExecuteScalar, olecomm.CommandText)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top