executing SQL? 
Author Message
 executing SQL?

Hello all,

I am using Visual Studio .NET to create my reports. I am connecting to the
database through ODBC, but I am not able to execute the SQL query and
create report from that query. Here is the sample code I have in my click
event of a button:

Private Sub btnCreateReport_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnCreateReport.Click

        Dim cn As OdbcConnection
        Dim mystring As String = "Select * from pc WHERE priority_code =
1"
        Dim cmd As OdbcCommand = New OdbcCommand(mystring)
        cn = New OdbcConnection("dsn=DR_SYSTEM;uid=abc;pwd=xyz")
        cn.Open()

        MsgBox("Connected")

        cn.Close()

    End Sub

I don't know how to execute my query (mytstring) and create a report from
there. How do I execute my queries, and bind it to the report? What code
do I need to put in between connection open and close? (or anywhere else)

Any help will be really appreciate,
Aleem



Sat, 10 Dec 2005 00:34:03 GMT  
 executing SQL?
Hi
  I use the Brian book at www.crystalreportsbook.com by
Brian Bischof, it is free and informative. Please take a
look, normally I use DataSet to create Crystal Report
after that populate another dataset and put the data in
the new instance of the Crystal report that I create. All
in that book.

Good Luck

Quote:
>-----Original Message-----
>Hello all,

>I am using Visual Studio .NET to create my reports. I am
connecting to the
>database through ODBC, but I am not able to execute the
SQL query and
>create report from that query. Here is the sample code I
have in my click
>event of a button:

>Private Sub btnCreateReport_Click(ByVal sender As

System.Object, ByVal e
Quote:
>As System.EventArgs) Handles btnCreateReport.Click

>        Dim cn As OdbcConnection
>        Dim mystring As String = "Select * from pc WHERE
priority_code =
>1"
>        Dim cmd As OdbcCommand = New OdbcCommand(mystring)
>        cn = New OdbcConnection

("dsn=DR_SYSTEM;uid=abc;pwd=xyz")
Quote:
>        cn.Open()

>        MsgBox("Connected")

>        cn.Close()

>    End Sub

>I don't know how to execute my query (mytstring) and

create a report from
Quote:
>there. How do I execute my queries, and bind it to the
report? What code
>do I need to put in between connection open and close?
(or anywhere else)

>Any help will be really appreciate,
>Aleem

>.



Tue, 13 Dec 2005 04:09:55 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Executing sql scripts on a SQL server from Access

2. Executing SQL Server DTS package in VBA code

3. Executing SQL queries using modules via Jet

4. executing SQL from VBA without prompting user

5. errors different when executing SQL statements via recordset or connection object

6. Execute SQL query on a DataSet

7. Executing SQL Scripts

8. Executing SQL Server Stored Procedure from VB

9. Executing SQL Script

10. Executing SQL scripts in VB

11. vb and executing SQL

12. DB.Execute SQL stmt w/Access1.1 vs 2.0

 

 
Powered by phpBB® Forum Software