Link to home
Start Free TrialLog in
Avatar of smegghead
smeggheadFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Server & VB6

Hi,

I've just started looking at SQL-Server V7, I'm currently using a jet database and I'm looking to move my application over to SQLSERVER.

I've tried to be as standard as I can with my SQL statements throughout the code, i.e. not using any VB functions.

I optimistically thought that I would simply have to change the OpenDatabase command to connect to the ODBC DSN which points to the database on an SQL server. (ha ha ha)

I'm using a ODBC workspace and just using a

SET dbase=wsODBC.OpenDatabase(dsnname)

Which works fine, except that the only thing I can do with this is select statements, as soon as I try to run an update SQL statement, it say ODBC-Call failed (or something like that).

I'm just doing

delete * from [MyTable] where idx=1

surely this should work... is there any way of getting more detailed error reports from SQL ?? 'ODBC Call failed' doesn't help me much.

Another question, which I'll award points for separately (should I get a positive answer) is, can you create a database on a SQLsever remotely via VB code ???
Avatar of smegghead
smegghead
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Also, when I run a select statement on the database, the recordcount property is always -1. Is there a way of determining the number of records returned without 'movenext'ing and counting until the EOF is reached.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yeah, I know, I've started using ADO rather than DAO and it gives an error message .. blah blah blah near '*', so I whipped it out and hey presto...

I've also sorted out the -1 thing...

You can have the points, if you just answer this easy question...

Is it possible to open a JET (MS Access) database using an ADO connection without creating a DSN ???

And.. any ideas on the creating of a database remotely ???
To open Access file without DSN, use this:

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
             "Data Source=C:\...\JetPassword.MDB;" & _
             "Jet OLEDB:Database Password=MyPwd"
   MyConn.Open ConnectionString:=strConn

Take a look at article id Q191754 (where this example come from).

To create database using ADO, you need ADOX (in ADO 2.1 and higher).
Thank you...

PS. Q191754 / Q.191754 / EQ.191754 - I can't find....
Article ID like this are taken from the Microsoft Knowledge base (support.microsoft.com) in which you can search for exact article number.