• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

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 ???
0
smegghead
Asked:
smegghead
  • 3
  • 3
1 Solution
 
smeggheadAuthor Commented:
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.
0
 
Éric MoreauSenior .Net ConsultantCommented:
Remove the * in your Delete query like this:
delete from MyTable where idx=1
0
 
smeggheadAuthor Commented:
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 ???
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Éric MoreauSenior .Net ConsultantCommented:
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).
0
 
smeggheadAuthor Commented:
Thank you...

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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now