ADODB.Recordset Source

  • Thread starter Thread starter gsauns
  • Start date Start date
G

gsauns

I am upgrading an application from VB6 to .NET.
One of the forms, which synchronizes data across a network, did not
upgrade, so I copied the code and worked it out manually.

I am now having a problem with the following lines:

RS.Source = strSQL
RS.Open()

The program seems to avoid this code for a bit, then throws an error.
I also tried just: RS.Open(strSQL)
but that threw a different error... is there a better way to set the
source, which is a SQL string?
 
gsauns said:
I am upgrading an application from VB6 to .NET.
One of the forms, which synchronizes data across a network, did not
upgrade, so I copied the code and worked it out manually.

I am now having a problem with the following lines:

RS.Source = strSQL
RS.Open()

The program seems to avoid this code for a bit, then throws an error.
I also tried just: RS.Open(strSQL)
but that threw a different error... is there a better way to set the
source, which is a SQL string?

http://www.startvbdotnet.com/ado/sqlserver.aspx

You can use dr.("SqlField name") instead of ordinal position numbers, look
it up use Google.

Also you may have to use the Convert statement as well to set Variable type
from database field type.

You should go get yourself a good ADO.net book.
 
gsauns said:
The program seems to avoid this code for a bit, then throws an error.
I also tried just: RS.Open(strSQL)
but that threw a different error...

What are the errors?
 
Thanks guys... I will try those suggestions today. Yes, you're
absolutely right- never mind the fact this is my first foray into
database programming, period- any suggestions on a book?

Errors are:
3265- Item cannot be found in the collection corresponding to the
requested name or ordinal
or, more commonly:
5- Procedure call or argument is not valid.
 
My SQL command is legit... the problem is that I am not trying to READ
from a database. That part of my app works fine. It is when I am
trying to WRITE to the DB. It is trying to send from a local Access
database to a SQL Server 2005 database on a server.

The strange part is that the errors usually happen on the 2nd or 3rd
records the app tries to sync... it seems like the code simply skips
the two lines (RS.Source=strSQL; RS.Open()) the first 2 or 3 times
through before throwing the error.

The code builds the SQL string off of the source recordset (which is
from the local Access DB), and then goes for the insert on the
destination recordset (on the server). Both recordsets are passed to
the function by value. As I said, the SQL string is OK; all fields and
their types match up.
 
gsauns said:
Thanks guys... I will try those suggestions today. Yes, you're
absolutely right- never mind the fact this is my first foray into
database programming, period- any suggestions on a book?

Errors are:
3265- Item cannot be found in the collection corresponding to the
requested name or ordinal
or, more commonly:
5- Procedure call or argument is not valid.

If that's on the update part you're talking about in your following
post, then a field name in the recordset does not match the field name
on the table in the database or it's not there in the table, period.
 
Back
Top