Advertisement

11.06.2007 at 09:47PM PST, ID: 22943906
[x]
Attachment Details

ADO Coding with SQL Server and MS Access

Asked by peter_chong in Access Coding/Macros, MS SQL Server

Tags: access, vba, sql, server, ado

Dear EE members,
I would like to call an access macro. This macro will call the vba function with the following code
to insert record from MS Server to Access table, but I failed to make it. Any suggestion to resolve
this problem are welcome.

Code:
Function fnADO_test() As Boolean
    Dim adoCon As ADODB.Connection
    Dim sConnect As String
    Dim theQuery As String
   
    Set adoCon = New ADODB.Connection
       
sConnect = "Provider='sqloledb';Data Source=myDataSource;Initial Catalog=myDB;User ID =myUser;Password=myPassword;"
   
    Debug.Print sConnect
   
    adoCon.ConnectionString = sConnect
   
    adoCon.Open
       
    theQuery = _
    "INSERT INTO sTarget" & _
    " SELECT col2,col4,col6
    " FROM dbo_Prod " & _
    " WHERE col2 < col4 & _
    " ORDER BY col1;"

    Debug.Print theQuery
   
    MsgBox "Before Execute"
   
    adoCon.Execute theQuery, , adCmdText Or adExecuteNoRecords
       
    MsgBox "After Execute"
       
    Set adoCon = Nothing
End Function

Start Free Trial
[+][-]11.06.2007 at 09:52PM PST, ID: 20230098

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.06.2007 at 10:21PM PST, ID: 20230159

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.06.2007 at 10:23PM PST, ID: 20230168

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.06.2007 at 10:29PM PST, ID: 20230180

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.06.2007 at 10:49PM PST, ID: 20230217

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.06.2007 at 11:37PM PST, ID: 20230316

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.06.2007 at 11:40PM PST, ID: 20230321

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.07.2007 at 01:38AM PST, ID: 20230720

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.07.2007 at 01:44AM PST, ID: 20230744

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, MS SQL Server
Tags: access, vba, sql, server, ado
Sign Up Now!
Solution Provided By: kelvinsparks
Participating Experts: 1
Solution Grade: A
 
 
[+][-]11.07.2007 at 04:49AM PST, ID: 20231496

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.11.2007 at 05:16PM PST, ID: 20261560

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628