![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
In a code module - goto tools/References and make sure you have selected Microsoft ActiveX Data Objects 2.? Library *(make sure you select 2.5 or higher - don't use 2.1) Then ADODB is used like this (don't use your ODBC connection - it totally defeats the point of using ADO - plus, I don't think it works). ------------------------------------------------ Dim cmd As New ADODB.Command, RS As New ADODB.Recordset Dim db As DAO.Database, RS1 As DAO.Recordset, i As Integer cmd.ActiveConnection = "Provider=SQLOLEDB; Data Source=yourSqlSvr;Database=YourDB;Trusted_Connecti on=Yes" cmd.ActiveConnection.CursorLocation = adUseClient cmd.CommandType = adCmdText cmd.CommandText = "Select t1.* From tbl1 t1 Join tbl2 t2 On t1.ID = t2.ID And t1.fld1 = t2.fld2 Where fld1 = 'something'" Set RS = cmd.Execute Set db = CurrentDb Set RS1 = db.OpenRecordset("yourAccessTbl") '--here is where you transfer the date from '--the ADO recordset to the Access table '-- you need to use a DAO recordset Do While Not RS.EOF * RS1.AddNew * For i = 0 To rs.Fields.Count - 1 '--field count * * RS1(i) = RS(i) * * * * * * * * '--begins at 0 * Next * RS1.Update * RS.MoveNext Loop ------------------------------------------------ In this sample, RS and RS1 contain the exact same fields. Rich *** Sent via Developersdexhttp://www.developersdex.com*** |
#4
| |||
| |||
|
|
On Mar 25, 1:34*pm, Rich P <rpng... (AT) aol (DOT) com> wrote: In a code module - goto tools/References and make sure you have selected Microsoft ActiveX Data Objects 2.? Library *(make sure you select 2.5or higher - don't use 2.1) Then ADODB is used like this (don't use your ODBC connection - it totally defeats the point of using ADO - plus, I don't think it works). ------------------------------------------------ Dim cmd As New ADODB.Command, RS As New ADODB.Recordset Dim db As DAO.Database, RS1 As DAO.Recordset, i As Integer cmd.ActiveConnection = "Provider=SQLOLEDB; Data Source=yourSqlSvr;Database=YourDB;Trusted_Connecti on=Yes" cmd.ActiveConnection.CursorLocation = adUseClient cmd.CommandType = adCmdText cmd.CommandText = "Select t1.* From tbl1 t1 Join tbl2 t2 On t1.ID = t2.ID And t1.fld1 = t2.fld2 Where fld1 = 'something'" Set RS = cmd.Execute Set db = CurrentDb Set RS1 = db.OpenRecordset("yourAccessTbl") '--here is where you transfer the date from '--the ADO recordset to the Access table '-- you need to use a DAO recordset Do While Not RS.EOF * RS1.AddNew * For i = 0 To rs.Fields.Count - 1 '--field count * * RS1(i) = RS(i) * * * * * * * * '--begins at 0 * Next * RS1.Update * RS.MoveNext Loop ------------------------------------------------ In this sample, RS and RS1 contain the exact same fields. Rich *** Sent via Developersdexhttp://www.developersdex.com*** what I need is to create an ADO recordset pointing to "myAccessQuery" so that I can use the ADO's recordset getRows() function can this be done ? or do I need to change the "myAccessQuery" to a sql server view so that I can use * cmd.CommandText = "Select * From mySqlView"- Hide quoted text - - Show quoted text - |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
On Mar 25, 1:34*pm, Rich P <rpng... (AT) aol (DOT) com> wrote: In a code module - goto tools/References and make sure you have selected Microsoft ActiveX Data Objects 2.? Library *(make sure you select 2.5or higher - don't use 2.1) Then ADODB is used like this (don't use your ODBC connection - it totally defeats the point of using ADO - plus, I don't think it works). ------------------------------------------------ Dim cmd As New ADODB.Command, RS As New ADODB.Recordset Dim db As DAO.Database, RS1 As DAO.Recordset, i As Integer cmd.ActiveConnection = "Provider=SQLOLEDB; Data Source=yourSqlSvr;Database=YourDB;Trusted_Connecti on=Yes" cmd.ActiveConnection.CursorLocation = adUseClient cmd.CommandType = adCmdText cmd.CommandText = "Select t1.* From tbl1 t1 Join tbl2 t2 On t1.ID = t2.ID And t1.fld1 = t2.fld2 Where fld1 = 'something'" Set RS = cmd.Execute Set db = CurrentDb Set RS1 = db.OpenRecordset("yourAccessTbl") '--here is where you transfer the date from '--the ADO recordset to the Access table '-- you need to use a DAO recordset Do While Not RS.EOF * RS1.AddNew * For i = 0 To rs.Fields.Count - 1 '--field count * * RS1(i) = RS(i) * * * * * * * * '--begins at 0 * Next * RS1.Update * RS.MoveNext Loop ------------------------------------------------ In this sample, RS and RS1 contain the exact same fields. Rich *** Sent via Developersdexhttp://www.developersdex.com*** what I need is to create an ADO recordset pointing to "myAccessQuery" so that I can use the ADO's recordset getRows() function can this be done ? or do I need to change the "myAccessQuery" to a sql server view so that I can use * cmd.CommandText = "Select * From mySqlView" |
#7
| |||
| |||
|
|
On Mar 25, 3:56*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote: On Mar 25, 1:34*pm, Rich P <rpng... (AT) aol (DOT) com> wrote: In a code module - goto tools/References and make sure you have selected Microsoft ActiveX Data Objects 2.? Library *(make sure you select 2..5 or higher - don't use 2.1) Then ADODB is used like this (don't use your ODBC connection - it totally defeats the point of using ADO - plus, I don't think it works). ------------------------------------------------ Dim cmd As New ADODB.Command, RS As New ADODB.Recordset Dim db As DAO.Database, RS1 As DAO.Recordset, i As Integer cmd.ActiveConnection = "Provider=SQLOLEDB; Data Source=yourSqlSvr;Database=YourDB;Trusted_Connecti on=Yes" cmd.ActiveConnection.CursorLocation = adUseClient cmd.CommandType = adCmdText cmd.CommandText = "Select t1.* From tbl1 t1 Join tbl2 t2 On t1.ID = t2.ID And t1.fld1 = t2.fld2 Where fld1 = 'something'" Set RS = cmd.Execute Set db = CurrentDb Set RS1 = db.OpenRecordset("yourAccessTbl") '--here is where you transfer the date from '--the ADO recordset to the Access table '-- you need to use a DAO recordset Do While Not RS.EOF * RS1.AddNew * For i = 0 To rs.Fields.Count - 1 '--field count * * RS1(i) = RS(i) * * * * * * * * '--begins at0 * Next * RS1.Update * RS.MoveNext Loop ------------------------------------------------ In this sample, RS and RS1 contain the exact same fields. Rich *** Sent via Developersdexhttp://www.developersdex.com*** what I need is to create an ADO recordset pointing to "myAccessQuery" so that I can use the ADO's recordset getRows() function can this be done ? or do I need to change the "myAccessQuery" to a sql server view so that I can use * cmd.CommandText = "Select * From mySqlView" A DAO.Recordset has a GetRows method that does the same thing the ADODB.Recordset GetRows method does. If a two dimensional array is what you are after, you don't need to convert anything to ADO.- Hide quoted text - - Show quoted text - |
#8
| |||
| |||
|
|
On Mar 25, 8:54*pm, rkc <r... (AT) rkcny (DOT) com> wrote: On Mar 25, 3:56*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote: On Mar 25, 1:34*pm, Rich P <rpng... (AT) aol (DOT) com> wrote: In a code module - goto tools/References and make sure you have selected Microsoft ActiveX Data Objects 2.? Library *(make sure you select2.5 or higher - don't use 2.1) Then ADODB is used like this (don't use your ODBC connection - it totally defeats the point of using ADO - plus, I don't think it works). ------------------------------------------------ Dim cmd As New ADODB.Command, RS As New ADODB.Recordset Dim db As DAO.Database, RS1 As DAO.Recordset, i As Integer cmd.ActiveConnection = "Provider=SQLOLEDB; Data Source=yourSqlSvr;Database=YourDB;Trusted_Connecti on=Yes" cmd.ActiveConnection.CursorLocation = adUseClient cmd.CommandType = adCmdText cmd.CommandText = "Select t1.* From tbl1 t1 Join tbl2 t2 On t1.ID= t2.ID And t1.fld1 = t2.fld2 Where fld1 = 'something'" Set RS = cmd.Execute Set db = CurrentDb Set RS1 = db.OpenRecordset("yourAccessTbl") '--here is where you transfer the date from '--the ADO recordset to the Access table '-- you need to use a DAO recordset Do While Not RS.EOF * RS1.AddNew * For i = 0 To rs.Fields.Count - 1 '--field count * * RS1(i) = RS(i) * * * * * * * * '--begins at 0 * Next * RS1.Update * RS.MoveNext Loop ------------------------------------------------ In this sample, RS and RS1 contain the exact same fields. Rich *** Sent via Developersdexhttp://www.developersdex.com*** what I need is to create an ADO recordset pointing to "myAccessQuery" so that I can use the ADO's recordset getRows() function can this be done ? or do I need to change the "myAccessQuery" to a sql server view so that I can use * cmd.CommandText = "Select * From mySqlView" A DAO.Recordset has a GetRows method that does the same thing the ADODB.Recordset GetRows method does. If a two dimensional array is what you are after, you don't need to convert anything to ADO.- Hide quoted text - - Show quoted text - just tried it, behaviour is slightly different * dim rsT as dao.recordset * dim recArray as variant * strsql = "select * from ..." * Set rsT = CurrentDb.OpenRecordset(strSql) * If (Not (rsT.EOF)) Then * * *recArray = rsT.GetRows * * *lngRecCount = UBound(recArray, 2) + 1 * endif lngRecCount has a value of 1 * dim rsT as new adodb.recordset * dim recArray as variant * strSql = "Provider=Microsoft.jet.oledb.4.0;Data Source=" & _ * * * * * * * * *CurrentDb.Name & ";" * cnt.Open strSql * strsql = "select * from ..." * rst.open strSql, cnt * If (Not (rsT.EOF)) Then * * *recArray = rsT.GetRows * * *lngRecCount = UBound(recArray, 2) + 1 * endif lngRecCount has a value of 1465 (which correct) I believe this is related to the default value of the parameter passed to getRows() |
#9
| |||
| |||
|
|
On Mar 26, 11:29*am, Roger <lesperan... (AT) natpro (DOT) com> wrote: On Mar 25, 8:54*pm, rkc <r... (AT) rkcny (DOT) com> wrote: On Mar 25, 3:56*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote: On Mar 25, 1:34*pm, Rich P <rpng... (AT) aol (DOT) com> wrote: In a code module - goto tools/References and make sure you have selected Microsoft ActiveX Data Objects 2.? Library *(make sure you select 2.5 or higher - don't use 2.1) Then ADODB is used like this (don't use your ODBC connection - it totally defeats the point of using ADO - plus, I don't think it works). ------------------------------------------------ Dim cmd As New ADODB.Command, RS As New ADODB.Recordset Dim db As DAO.Database, RS1 As DAO.Recordset, i As Integer cmd.ActiveConnection = "Provider=SQLOLEDB; Data Source=yourSqlSvr;Database=YourDB;Trusted_Connecti on=Yes" cmd.ActiveConnection.CursorLocation = adUseClient cmd.CommandType = adCmdText cmd.CommandText = "Select t1.* From tbl1 t1 Join tbl2 t2 On t1.ID = t2.ID And t1.fld1 = t2.fld2 Where fld1 = 'something'" Set RS = cmd.Execute Set db = CurrentDb Set RS1 = db.OpenRecordset("yourAccessTbl") '--here is where you transfer the date from '--the ADO recordset to the Access table '-- you need to use a DAO recordset Do While Not RS.EOF * RS1.AddNew * For i = 0 To rs.Fields.Count - 1 '--field count * * RS1(i) = RS(i) * * * * * * * * '--begins at 0 * Next * RS1.Update * RS.MoveNext Loop ------------------------------------------------ In this sample, RS and RS1 contain the exact same fields. Rich *** Sent via Developersdexhttp://www.developersdex.com*** what I need is to create an ADO recordset pointing to "myAccessQuery" so that I can use the ADO's recordset getRows() function can this be done ? or do I need to change the "myAccessQuery" to a sql server view so that I can use * cmd.CommandText = "Select * From mySqlView" A DAO.Recordset has a GetRows method that does the same thing the ADODB.Recordset GetRows method does. If a two dimensional array is what you are after, you don't need to convert anything to ADO.- Hide quoted text - - Show quoted text - just tried it, behaviour is slightly different * dim rsT as dao.recordset * dim recArray as variant * strsql = "select * from ..." * Set rsT = CurrentDb.OpenRecordset(strSql) * If (Not (rsT.EOF)) Then * * *recArray = rsT.GetRows * * *lngRecCount = UBound(recArray, 2) + 1 * endif lngRecCount has a value of 1 * dim rsT as new adodb.recordset * dim recArray as variant * strSql = "Provider=Microsoft.jet.oledb.4.0;Data Source=" & _ * * * * * * * * *CurrentDb.Name & ";" * cnt.Open strSql * strsql = "select * from ..." * rst.open strSql, cnt * If (Not (rsT.EOF)) Then * * *recArray = rsT.GetRows * * *lngRecCount = UBound(recArray, 2) + 1 * endif lngRecCount has a value of 1465 (which correct) I believe this is related to the default value of the parameter passed to getRows() But you can use DAO.Recordset.GetRows to return the rows of a recordset as two dimensional array. *Isn't that the point?- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |