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 16829
"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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |