?
Solved

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

Posted on 1998-10-08
1
Medium Priority
?
376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
mskannan earned 100 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

771 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