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

Trouble connecting to database through VB

Status
Not open for further replies.

karenmierkalns

Programmer
May 10, 2001
54
CA
I am having some trouble actually making the connection. It worked fine when I was using a DSN, but I would like to use a connection string. Here is what I have:

With cryPrint
.ReportFileName = App.Path & "\DonationTotals.rpt"
.SelectionFormula = "{Donors.DonorID} = " & intDonorID

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConnection = strConnection & "Data Source="
strConnection = strConnection & App.Path & "\OurChurch.mdb;"
strConnection = strConnection & "Persist Security Info=False"

.Connection = strConnection
.Action = 1
End With

The error I am getting is "Unable to connect: incorrect log on parameters."

It was working when I had the Connect property set to "DSN=OurChurch", but I no longer want to use this. How can I use the connection string?

FYI: this is a valid connection string, as I am using it for my ado connection within my VB project.

Thanks in advance. - Karen
 
Why do you have to connect to the database? It's Access. The report knows about the .MDB so just run the report. Skip the connection stuff.
 
I would, but I am getting the same error. I assumed it was because it needed a connection. Why else would I be getting that error?

ie.

With cryPrint
.ReportFileName = App.Path & "\DonationTotals.rpt"
.SelectionFormula = "{Donors.DonorID} = " & intDonorID
.Action = 1
End With

This code above is producing an error. It is not the selection formula, because if I manually set it in Crystal Reports, and I retrieve it in VB, then it is identical. So, whenever I use selectionformula OR an sql query, I am given an error.

Any suggestions? - Karen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top