By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,569 Members | 1,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,569 IT Pros & Developers. It's quick & easy.

ado connection errors

P: 2
hi everyone,

i am using sql server 2005 to connect to a vb6 or earlier version app.
i appear to be having a problem with the connection string - i have been to http://www.connectionstrings.com with no luck.

my script looks as follows:
code looks as follows:

Expand|Select|Wrap|Line Numbers
  1. function LaunchApp()
  2. {
  3.   var result, Cmd; 
  4.  
  5.    sqlQryLaunchSDH = "select colname from table";
  6.  
  7.     openConnection();
  8.  
  9.     // Create a new object
  10.   Cmd = ADO.CreateADOCommand();
  11.   // Specify the command type
  12. //      Cmd.ActiveConnection = conn; = this is not supported
  13.  
  14.  
  15.       Cmd.CommandType = adCmdText;   
  16.  
  17.       // Specify the command text (the SQL expression)
  18.  
  19.       Cmd.CommandText = sqlQryLaunchSDH; //read in text qry
  20.  
  21.         // Execute the command
  22.  
  23.       result = Cmd.Execute(); //does not work Missing Connection or ConnectionString exception
  24.  
  25.  
  26. function openConnection()
  27. {
  28.   conn = ADO.CreateConnection();
  29.  
  30.   conn.ConnectionString = "Driver={SQL Native Client};Server=servername\\instancename;Database=dbname;Trusted_Connection=yes;";
  31.  conn.Open();
  32.  }
Initially i received the following error:

1] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I then changed the connection string however I then ended up with this error

2] Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done

3] Now with the code above I am able to make progress until I get to results = Cmd.Execute()

Where I get ‘Missing Connection or ConnectionString’ exception

anyone experience this problem before?
Mar 11 '08 #1
Share this Question
Share on Google+
3 Replies


jeffstl
Expert 100+
P: 432
hi everyone,

i am using sql server 2005 to connect to a vb6 or earlier version app.
i appear to be having a problem with the connection string - i have been to http://www.connectionstrings.com with no luck.

my script looks as follows:
code looks as follows:

Expand|Select|Wrap|Line Numbers
  1. function LaunchApp()
  2. {
  3.   var result, Cmd; 
  4.  
  5.    sqlQryLaunchSDH = "select colname from table";
  6.  
  7.     openConnection();
  8.  
  9.     // Create a new object
  10.   Cmd = ADO.CreateADOCommand();
  11.   // Specify the command type
  12. //      Cmd.ActiveConnection = conn; = this is not supported
  13.  
  14.  
  15.       Cmd.CommandType = adCmdText;   
  16.  
  17.       // Specify the command text (the SQL expression)
  18.  
  19.       Cmd.CommandText = sqlQryLaunchSDH; //read in text qry
  20.  
  21.         // Execute the command
  22.  
  23.       result = Cmd.Execute(); //does not work Missing Connection or ConnectionString exception
  24.  
  25.  
  26. function openConnection()
  27. {
  28.   conn = ADO.CreateConnection();
  29.  
  30.   conn.ConnectionString = "Driver={SQL Native Client};Server=servername\\instancename;Database=dbname;Trusted_Connection=yes;";
  31.  conn.Open();
  32.  }
Initially i received the following error:

1] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I then changed the connection string however I then ended up with this error

2] Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done

3] Now with the code above I am able to make progress until I get to results = Cmd.Execute()

Where I get ‘Missing Connection or ConnectionString’ exception

anyone experience this problem before?
This doesn't look like VB6.0 to me. This looks like a java or javascript or .NET framework stuff......

I can't tell where your specific problems are because your comments are overlapping to the next lines and its hard to tell if those are set up right. Also make sure conn is declared globally. Not sure other then that. sorry.
Mar 11 '08 #2

P: 2
This doesn't look like VB6.0 to me. This looks like a java or javascript or .NET framework stuff......

I can't tell where your specific problems are because your comments are overlapping to the next lines and its hard to tell if those are set up right. Also make sure conn is declared globally. Not sure other then that. sorry.
Hi jeffstl
this is javascript but the app that this test script is running against is vb 6

function LaunchApp()
{
var conn, Cmd, result;

sqlQry = "select colname from table";

conn = ADO.CreateConnection();
conn.ConnectionString = "Driver={SQL Native Client};Server=servername\\instancename;Database=d bname;Trusted_Connection=yes;";
conn.Open();

Cmd = ADO.CreateADOCommand();
Cmd.CommandType = adCmdText;

Cmd.CommandText = sqlQry

result = Cmd.Execute();
}

At the point results = Cmd.Execute() I get ‘Missing Connection or ConnectionString’ exception regardless of where the connection string is sitting
Mar 19 '08 #3

QVeen72
Expert 100+
P: 1,445
Hi,

You Need to set Active Connection for Command object:

Set Cmd.ActiveConnection = Conn
Cmd.CommandType = adCmdText;
Cmd.CommandText = sqlQry

REgards
Veena
Mar 19 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.