To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Database Development

Reply Post New Thread
 
Thread Tools Display Modes
Old Feb 26th, 2001, 09:26 AM   #1
SmagO
Lively Member
 
Join Date: Aug 00
Location: South Africa
Posts: 113
SmagO is an unknown quantity at this point (<10)
Question

Hi all,
please leme knoe how to execute an access query from vb
I need to run a make table query...

sqlq = "SELECT ned_rpt_case_stats.* INTO temp " & _
" FROM ned_rpt_case_stats"

thats my query
now i always just put in a data structure from the toolbox and call it datSQL. then i go datsql.recordsource=sqlq...
but now i need the query to actually execute from vb so that the table in access gets created

thanks ina advance
__________________
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!
SmagO is offline   Reply With Quote
Old Feb 26th, 2001, 12:03 PM   #2
Jeff Carlin
Lively Member
 
Join Date: Nov 00
Posts: 82
Jeff Carlin is an unknown quantity at this point (<10)
I'm not sure if I'm missing something here, but...

Assuming your database name is "MyDB", you can execute any valid SQL statement against the database as follows:
Code:
MyDB.Execute MySQLStatement
Jeff Carlin is offline   Reply With Quote
Old Feb 27th, 2001, 01:14 AM   #3
SmagO
Lively Member
 
Join Date: Aug 00
Location: South Africa
Posts: 113
SmagO is an unknown quantity at this point (<10)
but how do i set up the database

thanks but...
please show me how to set the database up
i have always used record sources and dont know how to dim the database and then show where it is attached to
__________________
You are living a pacifist dream, and if you dreaming it means you sleeping and you should damn well wake up!
SmagO is offline   Reply With Quote
Old Feb 27th, 2001, 01:41 AM   #4
TheBao
Fanatic Member
 
Join Date: Jan 01
Location: Vietnam
Posts: 613
TheBao is an unknown quantity at this point (<10)
Hi SmagO,

Please try this, I think it is what you are looking for:
Code:
Dim con As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset

Private Sub Command1_Click()
    Set cmd = New ADODB.Command
    With cmd
        .ActiveConnection = con
        .CommandType = adCmdUnknown
        
        'execute the Invoice query
        .CommandText = "Invoices"
        Set rs = .Execute
    End With
    
    'testing it
    Dim counter As Integer
    For counter = 0 To rs.Fields.Count - 1
        Debug.Print rs.Fields(counter).Value
    Next
End Sub

Private Sub Form_Load()
    'connect to Northwind access file
    Set con = New ADODB.Connection
    con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb;Persist Security Info=False"
    con.Open
End Sub

Regards,
TheBao
TheBao is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Database Development


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:40 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.