Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing a Insert Query with ODBC Connection 1

Status
Not open for further replies.

ghost2

Programmer
Aug 7, 2003
145
0
0
US
Hello all. I have code that I use to fill a dataset and then loop through it. This is an ODBC Database connection to an Advantage database that I had to use ODBC for. The code I have to do the fill is:
Dim strConn As String = "DSN=CSTEST"
Dim objConn As New Odbc.OdbcConnection(strConn)
Dim objCmd As New Odbc.OdbcCommand
Dim objDA As New Odbc.OdbcDataAdapter

strSQL = "SELECT PAYMENT.co_code, count(PAYMENT.Qual_no) AS NEWENROLLEES " & _
"FROM CO_MAST RIGHT JOIN PAYMENT ON CO_MAST.CO_CODE = PAYMENT.CO_CODE " & _
"WHERE CO_MAST.CO_STATUS = True " & _
"GROUP BY co_code"

objDA = New Odbc.OdbcDataAdapter(strSQL, objConn)

objDA2.Fill(ds2, "PAYMENT")

HOW DO I JUST EXECUTE A QUERY LIKE THIS:
strSQL = ""
strSQL = "SELECT DISTINCT co_code, Qual_no, min(paid_date) As PaidDate " & _
"INTO TMPPAIDDATES FROM PAYMENT " & _
"GROUP BY co_code, Qual_no"
 
Here is some pseudocode:

Code:
Dim InsertCommand As Command
InsertCommand.Connection = YourConnection
InsertCommand.CommandType = CommandType.Text
InsertCommand.CommandText = strSQL
InsertCommand.ExecuteNonQuery()
 
Riverguy,

I know this post is a couple of years old, but it just saved my bacon.

Thanks,

MBeth6
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top