Solved

ado data control connection string

Posted on 2003-12-09
4
1,357 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month6 days, 12 hours left to enroll

623 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