Hello,
I am trying to update records in my database from excel data using vba
editor within excel.
In order to launch a query, I use SQL langage in ADO as follwing:
------------------------------------------------------------
Dim adoConn As ADODB.Connection
Dim adoRs As ADODB.Recordset
Dim sConn As String
Dim sSql As String
Dim sOutput As String
sConn = "DSN=MS Access Database;" & _
"DBQ=MyDatabasePath;" & _
"DefaultDir=MyPathDirectory;" & _
"DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" &
_
"PWD=xxxxxx;UID=admin;"
ID, A, B C.. are my table fields
sSql = "SELECT ID, `A`, B, `C being a date`, D, E, `F`, `H`, I, J,
`K`, L" & _
" FROM MyTblName" & _
" WHERE (`A`='MyA')" & _
" AND (`C`>{ts '" & Format(Date, "yyyy-mm-dd hh:mm:ss") & "'})"
& _
" ORDER BY `C` DESC"
Set adoConn = New ADODB.Connection
adoConn.Open sConn
Set adoRs = New ADODB.Recordset
adoRs.Open Source:=sSql, _
ActiveConnection:=adoConn
adoRs.MoveFirst
Sheets("Sheet1").Range("a2").CopyFromRecordset adoRs
Set adoRs = Nothing
Set adoConn = Nothing
---------------------------------------------------------------
Does Anyone know How I can use the UPDATE, DELETE INSERT SQL statements
in this environement? Copying SQL statements from access does not work
as I would have to reference Access Object in my project which I do not
want if I can avoid. Ideally I would like to use only ADO system and
SQL approach.
Thank you very much
Nono 1 16792
"Nono" <no**********@yahoo.fr> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... Hello, I am trying to update records in my database from excel data using vba editor within excel. In order to launch a query, I use SQL langage in ADO as follwing: ------------------------------------------------------------ Dim adoConn As ADODB.Connection Dim adoRs As ADODB.Recordset Dim sConn As String Dim sSql As String Dim sOutput As String
sConn = "DSN=MS Access Database;" & _ "DBQ=MyDatabasePath;" & _ "DefaultDir=MyPathDirectory;" & _ "DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;" & _ "PWD=xxxxxx;UID=admin;"
ID, A, B C.. are my table fields sSql = "SELECT ID, `A`, B, `C being a date`, D, E, `F`, `H`, I, J, `K`, L" & _ " FROM MyTblName" & _ " WHERE (`A`='MyA')" & _ " AND (`C`>{ts '" & Format(Date, "yyyy-mm-dd hh:mm:ss") & "'})" & _ " ORDER BY `C` DESC" Set adoConn = New ADODB.Connection adoConn.Open sConn
Set adoRs = New ADODB.Recordset adoRs.Open Source:=sSql, _ ActiveConnection:=adoConn
adoRs.MoveFirst Sheets("Sheet1").Range("a2").CopyFromRecordset adoRs Set adoRs = Nothing Set adoConn = Nothing
--------------------------------------------------------------- Does Anyone know How I can use the UPDATE, DELETE INSERT SQL statements in this environement? Copying SQL statements from access does not work as I would have to reference Access Object in my project which I do not want if I can avoid. Ideally I would like to use only ADO system and SQL approach.
Thank you very much
Nono
This seems to be an Access question, not an MSSQL one, so you'll probably
get a better response in an Access or ADO group. But if you can build up a
SELECT statement dynamically, then you should be able to build an UPDATE
also - it's not really clear from your post why this isn't working for you.
Simon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: pb648174 |
last post by:
I have a single update statement that updates the same column multiple
times in the same update statement. Basically i have a column that
looks like .1.2.3.4. which are id references that need to...
|
by: serge |
last post by:
/*
This is a long post. You can paste the whole message
in the SQL Query Analyzer.
I have a scenario where there are records
with values pointing to wrong records and I need to fix them
using an...
|
by: ImraneA |
last post by:
Hi there
Many thanks to those people who contributed to this group, helped me
greatly.
Enclose, my code, hope it helps others :-
Public Function Export_Excel_9(tbx1 As Variant, tbx2 As...
|
by: C |
last post by:
Re: Microsoft Knowledge Base Article - 870669
How to disable the ADODB.Stream object from Internet Explorer
You may recently have heard of the vulnarability exposed by Internet
Explorer as...
|
by: Steve |
last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement
I got ASP error number 13 when I use the SELECT...FOR UPDATE statement
as below.
However, if I use SELECT statement without...
|
by: Dodong |
last post by:
Hi, i am a new vb6 programmer. I would like to know the vb6 code to read excel file and save it to access database. I am using ADO.
|
by: buttons |
last post by:
I was given a project to figure out how to use Workforce data stored in Excel spreadsheet (Various Formulas such as Data for ethnicity, gender, new hires, turnover, etc) that can be converted into a...
|
by: p.numminen |
last post by:
How I convert an Excel spreadsheet into an Access database?
This is Office 2003.
|
by: rlsj |
last post by:
I noticed EXCEL can automatically update a list from SharePoint services.
Is there a quick and easy way to update a list from an Access query?
Is it "better" to create the code in ACCESS...
|
by: satenova |
last post by:
Hello Friends,
I am newbie when it comes to vb.net and i need to import excel sheet into access db using vb.net application. Here is the code i use for now to upload excel sheet and it works...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |