Solved

ado data control connection string

Posted on 2003-12-09
4
1,344 Views
Last Modified: 2013-11-23
Hi
I'm using VB6 with access97,
one of my forms contains an adodc,
can I give a connection string after the application starts instead of
putting it in the connectionString property in the properties window?
I need to do so because my connection string is created after the application start running.
I tried putting on sub Form_Load the following code:
adodc.connectionString strConn
But it didnt work.
Thanks .
0
Comment
Question by:zolpo
  • 3
4 Comments
 
LVL 1

Expert Comment

by:carpe-diem
ID: 9905297
Yes, you can declare every thing you want inside your app and then call the connection.
Here is some sample code I've used.

Dim cnn3 As ADODC.Connection
Dim strCnn3 As String

Set cnn3 = New ADODC.Connection
strCnn3 = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID = _ sa;Password=password;InitialCatalog=ADVANCE_DEV;Data Source=ZEUS"
cnn3.Open strCnn3
' then set the chassis serial number
If strYear = "2003" Then
cnn3.Execute "UPDATE VBLD_CHASSIS_SERIAL SET CHASSIS_SERIAL = (SELECT     '1' + [YEAR] + RIGHT(STR(SEQUENCE), 4) -1 From VBLD_CHASSIS_SERIAL WHERE ORDER_NO = '" & txtOrder & "') WHERE ORDER_NO = '" & txtOrder & "'"
Else
cnn3.Execute "UPDATE VBLD_CHASSIS_SERIAL SET CHASSIS_SERIAL = (SELECT     '1' + [YEAR] + RIGHT(STR(SEQUENCE), 4) From VBLD_CHASSIS_SERIAL WHERE ORDER_NO = '" & txtOrder & "') WHERE ORDER_NO = '" & txtOrder & "'"
End If
0
 
LVL 1

Expert Comment

by:carpe-diem
ID: 9905327
Sorry, if you want to connect to access you will need a connection string along the lines of;

Provider=Microsoft.Jet.OLEDB.4.0;Password="";Data Source=E:\temp\eScheduling51\Export\DataWarehouse.mdb;Persist Security Info=True

the string shown in the previous note shows a connection to an ms SQL database
0
 
LVL 1

Expert Comment

by:carpe-diem
ID: 9905736
I've just noticed a spelling mistake in my answer, everywhere you see ADODC should be replaced with ADODB
0
 
LVL 29

Accepted Solution

by:
leonstryker earned 100 total points
ID: 9906595
For a data control you would need to do this;

    With Adodc1
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password="";Data Source=E:\temp\eScheduling51\Export\DataWarehouse.mdb;Persist Security Info=True"
        .CommandType = adCmdUnknown
        strSQL = "SELECT * FROM Table "
        .RecordSource = strSQL
    End With

Leon
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now