Solved

How to do a sql command ("Insert into ...") with ODBC

Posted on 1998-10-08
1
335 Views
Last Modified: 2012-05-04
Hi,

I want to do a direct sql command ("Insert into ...") with an ODBC connection.

I use vba excel (97) but i think it the same syntax in vb.

Thanks
0
Comment
Question by:didede
1 Comment
 

Accepted Solution

by:
mskannan earned 50 total points
ID: 1438805
Hi didede,
I am giving you a simple code in VB to insert into a database

dim en as rdoenvironment
set en= rdoenvironments(0)
dim cn as rdoconnection
dim conn as string
conn$ = "DSN=temp;UID=sa;PWD=;DATABASE=emp;
set cn=en.openconnection("",rddrivernoprompt,false,conn$)
dim mysql as string;
mysql="Insert into employee values('James',26,'14/12/72');"
dim myQry as rdoquery
myqry.sql = mysql
myqry.execute
myqry.close
cn.close

Better try this one and feedback.
mskannan.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 115
DIR issue 7 54
Reading the Contents of a Directory In Access VBA 5 68
Send outlook email from VBS Script 2 28
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

786 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