Link to home
Start Free TrialLog in
Avatar of zolpo
zolpo

asked on

ado data control connection string

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 .
Avatar of carpe-diem
carpe-diem

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
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
I've just noticed a spelling mistake in my answer, everywhere you see ADODC should be replaced with ADODB
ASKER CERTIFIED SOLUTION
Avatar of leonstryker
leonstryker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial