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

ado connection string

Status
Not open for further replies.

mans

Programmer
Mar 18, 2000
136
AU
Hello,

I am using the code below within the connection string (Property Pages) window for an ado control. When I enter the code below and click apply it says "authentification failed" and at run time it says that my code does not comply with OLE DB specifications.

Can somebody please pick what the problem is with my statement below, I have a feeling it is a syntax problem.

I am using VB6 and a secured Access2000 database. I had no problems with my code when I hard coded the database and the .mdw file locations, now that I am using the App.Path statement there is a problem.


Provider=Microsoft.Jet.OLEDB.4.0;Password=pw;User ID=user;Data Source= =" & App.Path & "\db.mdb";Persist Security Info=True;Jet OLEDB:System database=" & App.Path & "\security.mdw";Jet OLEDB:Database Password=pw

Thank You [sig][/sig]
 
I have had this problem. It seems that sometimes when using the app.path in the VB's IDE, VB looks at it's OWN app.path, i.e. the path where the vb6.exe resides. Oddly enough, it doesn't ALWAYS do this, and I have not determined what the defining conditions are. I had to use a hard-coded path for development and put in the app.path code for the compile. [sig][/sig]
 
If I understad what your saying is that you typed that connection string into the ConnectionString property of the
ADO control's property window. If so, I think the property window assumes every thing in that property is one big text string.
Try coding the ConnectionString property in , for example the Form Load Event and it should work.

Collin

[sig][/sig]
 
Thanks for your responses. I hard coded the connection string within the Property Pages window then placed the code below in the Form_Load event. The program still looks into the directory where VB6.exe resides (instead of App.Path..), have I set out the code correctly (below)? The object I am using is named Adodc1.

I made the code below equal to Adodc1.ConnectionString (is that correct??), or do I need to set up some connection first (the program will not allow me to establish a new connection (probably because the connection exists))??

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=pw;User ID=user;Data Source=" & App.Path & "\db.mdb;Persist Security Info=True;Jet OLEDB:System database=" & App.Path & "\security.mdw & ";Jet OLEDB:Database Password=pw"

Adodc1.RecordSource = ("Select * From Table1")

Please let me know

Thanks
 
Hi-

Try to put a new ADO control on your form and leave the default settings and then in your form load events put your code.

Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=pw;User ID=user;Data Source=" & App.Path & "\db.mdb;Persist Security Info=True;Jet OLEDB:System database=" & App.Path & "\security.mdw;Jet OLEDB:Database Password=pw"

Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "Select * from Table1"

Set Text1(0).DataSource = Adodc1
Text1(0).DataField = "Field1"

Set Text1(1).DataSource = Adodc1
Text1(1).DataField = "Field2"

End Sub

One more thing remove any settings you've put on DATASOURCE, DATAFIELD of any controls that was previously bounded to the ADO control and it should work.

 
Check to be sure that App.path is, in your case, not returning the \. It sometimes does and sometimes does not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top