Solved

ado data control connection string

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Put text in a picture ASP.NET C# 2 50
VBA/SQL - Connect to SQL server and pull data 4 88
Adoquery sql  left join does not work 25 80
update joined tables 2 31
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

867 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

18 Experts available now in Live!

Get 1:1 Help Now