Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Using ADODB

Reply
 
Old 10-08-2008   #1 (permalink)
Sparkie


 
 

Using ADODB

I'm trying to edit an SQL database using the ADODB object, using Mircosoft
SQL Server 2005 Express. The script runs from the command line not from a
WEB page.

If I have Attached to the database using server management studio, then I
can open the database, but if I have not already attached to the database
then the processs fails.

The Current Code I have is

Dim oSQLServer
Dim sConnectionString
sConnectionString = "Driver={SQL Server};Server=KDANCERLTXP;
Database=i96X;Uid=sa;Pwd=XXXX;"
Set oSQLServer = CreateObject("ADODB.Connection")
oSQLServer.Open sConnectionString

If SQL Server has not already attached to the data base how do I use the
ADODB object to attach to the database before I open it?



My System SpecsSystem Spec
Old 10-08-2008   #2 (permalink)
Joe Fawcett


 
 

Re: Using ADODB

It maybe because SQLExpress catalogues are loaded from a file when needed
unlike regular SQL ones.
I wouldn't use ODBC connection (the 'driver' keyword means it's using ODBC).
Take a look at http://www.connectionstrings.com and pick one the more modern
connection strings such as:

Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes;

(under SQL 2005 section, you may want to use username/password instead of
Windows authentication)
Alternatively use:

Server=myServerAddress\SQLExpress;Database=myDataBase;User
ID=myUsername;Password=myPassword;Trusted_Connection=False;

(SQL Express usually runs as a named instance)
--

Joe Fawcett (MVP - XML)

http://joe.fawcett.name



"Sparkie" <Sparkie@xxxxxx> wrote in message
news:0741FF0F-A40F-4D37-B786-CF81B2415074@xxxxxx
Quote:

> I'm trying to edit an SQL database using the ADODB object, using Mircosoft
> SQL Server 2005 Express. The script runs from the command line not from a
> WEB page.
>
> If I have Attached to the database using server management studio, then I
> can open the database, but if I have not already attached to the database
> then the processs fails.
>
> The Current Code I have is
>
> Dim oSQLServer
> Dim sConnectionString
> sConnectionString = "Driver={SQL Server};Server=KDANCERLTXP;
> Database=i96X;Uid=sa;Pwd=XXXX;"
> Set oSQLServer = CreateObject("ADODB.Connection")
> oSQLServer.Open sConnectionString
>
> If SQL Server has not already attached to the data base how do I use the
> ADODB object to attach to the database before I open it?
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Error using SUM() with the ADODB Object VB Script
Using SUM with ADODB object VB Script
migrating vb6 code using adodb .NET General
ADODB: com and .net PowerShell
Powershell 32 vs. 64 when using ADODB PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46