Solved

ado data control connection string

Posted on 2003-12-09
4
1,356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi Spellcheck in Webbrowser 1 77
Why can't I create any project with my delphi EXE file? 6 59
MS Access from Delphi 31 106
Macro problems with Excel file 6 53
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 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