Home » SQL & PL/SQL » SQL & PL/SQL » How to run SQL from an application?
How to run SQL from an application? [message #6504] Tue, 22 April 2003 11:14 Go to next message
Sotorin
Messages: 1
Registered: April 2003
Junior Member
I'd like to run a simple SQL statement from VB application. Let's say I have VB form, some SQL in somesql.sql file, appropriate cridentials on a database server and I'd like to be able to press a button on this form and run that SQL statement. How can I do this?
Re: How to run SQL from an application? [message #6520 is a reply to message #6504] Wed, 23 April 2003 02:45 Go to previous message
shawlin
Messages: 25
Registered: April 2003
Junior Member
Open a database connection using ADO object
and then open a recordset

I presume u have a database connection.

If that being a case

declare a variable string
dim sStr as string
dim sEmpno as string
dim sEname as string
dim Recset as adodb.recordset

sStr = ""
sstr = sstr + " select empno,ename from emp"
sstr = sstr + " where column_name" - if any where Clause

set Recset = ado_connect.execute(sstr)

if Recset.eof = false then
sEmpno = "" & Recset!empno
sEname = "" & Recset!ename
end if

This how u run the desired sql statement
in VB(vb6.0).

Hope this is what you are asking for.
Are u had any other thing in the mind.

Thanks and regards
shawlin
Previous Topic: how to know database name from sql prompt in oracle
Next Topic: droping table(s)
Goto Forum:
  


Current Time: Fri Apr 19 15:48:38 CDT 2024