Insert Records from SQL Server Passthrough Query 
Author Message
 Insert Records from SQL Server Passthrough Query

Hello,

I am creating a connection to a SQL Server 7 database without using a DSN,
and executing a stored procedure.  I need to insert the recordset to a
table.  Do I need to loop through the recordset, or is there an SQL way of
doing this
(i.e. INSERT INTO MyTable  SELECT MyRecord FROM ???)

Thanks in advance, S{*filter*}

Below is my connection string:

   Dim cnnFlash As New ADODB.Connection, rsFlash As ADODB.Recordset
   Dim strParm00 As String, strParm01 As String, strParm02 As String

   strParm01 = "CustomerContract"
   strParm02 = "ListPrice"
   strParm00 = "'" & strParm01 & "', " & "'" & strParm02 & "'"

'Open a connection by referencing the ODBC driver.
cnnFlash.Open "Driver={SQL
Server};Server=MyServer;uid=Test;pwd=test123;Database=dbMySS7"

' Create a Recordset by executing an SQL statement.
   Set rsFlash = cnnFlash.Execute("spTest " & strParm00, adCmdStoredProc)



Sat, 14 Feb 2004 06:00:57 GMT  
 Insert Records from SQL Server Passthrough Query
No. You should create another stored procedure that does the insert.


Quote:
> Hello,

> I am creating a connection to a SQL Server 7 database without using a DSN,
> and executing a stored procedure.  I need to insert the recordset to a
> table.  Do I need to loop through the recordset, or is there an SQL way of
> doing this
> (i.e. INSERT INTO MyTable  SELECT MyRecord FROM ???)

> Thanks in advance, S{*filter*}

> Below is my connection string:

>    Dim cnnFlash As New ADODB.Connection, rsFlash As ADODB.Recordset
>    Dim strParm00 As String, strParm01 As String, strParm02 As String

>    strParm01 = "CustomerContract"
>    strParm02 = "ListPrice"
>    strParm00 = "'" & strParm01 & "', " & "'" & strParm02 & "'"

> 'Open a connection by referencing the ODBC driver.
> cnnFlash.Open "Driver={SQL
> Server};Server=MyServer;uid=Test;pwd=test123;Database=dbMySS7"

> ' Create a Recordset by executing an SQL statement.
>    Set rsFlash = cnnFlash.Execute("spTest " & strParm00, adCmdStoredProc)



Sat, 14 Feb 2004 07:05:52 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Selecting Records on a SQL Server via PassThrough?

2. need ID from newly inserted record (altered by insert trigger on SQL server)

3. SQL passthrough queries.....ODBC

4. Problems inserting records into SQL Server

5. Problem With Inserting Over 1200o records into SQL server 6.5

6. Inserting records from one database table to another in SQL Server

7. Insert records in a SQL Server via DBGrid

8. Insert records in a SQL Server via DBGrid

9. VB4.0 Insert Record SQL Server 6.5

10. Inserting records into SQL Server

11. Finding the identity of the last record inserted in SQL Server

12. Insert records in a SQL Server via DBGrid

 

 
Powered by phpBB® Forum Software