Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 25, 2012, 12:57:00 PM

Pages: [1]   Go Down
  Print  
Author Topic: VBScript launched from Plesk's Scheduler & our MSSQL conn str *** RESOLVED ***  (Read 764 times)
Comet Software
Spacescooter Operator
*****
Offline Offline

Posts: 34


« on: August 09, 2011, 06:14:12 AM »

We are trying to get our first ASP.NET application up and we have run into an issue with a VBScript file that we are launching from Plesk's Scheduler.

We have successfully created the MSSQL database, captured the connection string as provided by myLittleAdmin (we did not see where it created a connection name aka DSN), and, ran several ASP.NET pages that have accessed the MSSQL database.  Then, we set up a VBScript file as a scheduled task and passed the connection string as a command line parameter.  But, when it tries to open the connection, it generates an error.  Our connection string (as generated by myLittleAdmin) looks like this:

     Data Source=209.200.235.3;Network Library=;Connection Timeout=2000;Packet Size=4096;Integrated Security=no;
                          User ID=myUser;Encrypt=no;Initial Catalog=myDatabase;

In the VBScript file, we have statements like these:

     dim myConn
     myConn = "Data Source=209.200.235.3;Network Library=;Connection Timeout=2000;Packet Size=4096;Integrated Security=no;
                          User ID=myUser;Password=myPassword;Encrypt=no;Initial Catalog=myDatabase;"
     dim objConn
     Set objConn = CreateObject("ADODB.Connection")
     objConn.Open = myConn

The "open" statement generates this error:

     Microsoft OLE DB Service Components: Multiple-step OLE DB operation generated errors. Check each OLE DB status value,
     if available. No work was done.

Since this VBScript file is launched from Scheduler, we know that it is being launched successfully.  Yes, the connection string is getting into the VBScript file as a command line parameter, but, we have surrounded that value with double quotes on the command line and we have put in a wscript.echo statement to verify that the complete connection string is there.  

Next, we tried inserting this at the beginning of the connection string:

     Provider=SQLOLEDB;

But, the "open" statement generates the same error.

When we submitted a Help Ticket to Lunarpages support and asked them to tell us what was wrong with the connection string, their first response was to tell us use an ODBC connection, which meant creating an ODBC connection in Plesk and changing the ADODB in the VBScript file to ODBC.  The first problem with that is that Plesk does not show us a "connection string" when we created the ODBC connection - just a connection name.  Second, the CreateObject("ODBC.Connection") statement generated this error before processing gets to the open statement:

     ActiveX component can't create object: 'ODBC.Connection'

When we updated the Help Ticket with this information, their response was:

     I'm gald (sic) that the error was fixed.
     I was about to ask you to check the format of the connection string in the VBScript.
     You can enable error reporting to have a better view of the cause:

and then proceeded to give us an example of how to display VBScript errors in VBScript code within an ASP.NET page.

--head--desk--

We have Googled this error and basically the main conclusion seems to be that there is some type of data type mismatch (when run from an ASP page) or that the connection string is messed up.  When we tested this script locally, we set the objConn.CursorLocation to adUseClient after the dim and prior to the open.  On the server, we have tried it with adUseClient, adUseServer, and, not setting the value at all - but, it makes no difference in generating the error on the open statement.  So, it would seem that this problem is isolated to VBScript trying to open with a connection string that we know works in ASP.NET pages.

Any ideas as to why our ASP.NET pages like that connection string but VBScript does not?


« Last Edit: August 10, 2011, 04:31:03 PM by Comet Software » Logged
Comet Software
Spacescooter Operator
*****
Offline Offline

Posts: 34


« Reply #1 on: August 10, 2011, 05:18:54 PM »

First, we corrected the original post (OP) to this thread to reflect that the connection string generated/supplied by myLittleAdmin does NOT include the "Password" attribute.  We thought that if the user was specified that it made sense that the password would be required, so, we included it on all future testing.

As to the solution, the myLittleAdmin connection string does not include a "Provider" attribute, so, as stated in the OP we tried adding the "Provider=SQLOLEDB;" attribute, but, that did not change the error message.  Although Lunarpages tech support still seemed to think that there was a syntax error in the connection string, we stated that Googling indicated that it wasn't a syntax error.  We specifically asked about "Provider" and they replied that the provider should be "Provider=SQLOLEDB.1;" and that changed the error message to:

     Microsoft OLE DB Provider for SQL Server: Invalid connection string attribute

This tells us that we have hit upon the correct provider, but, some other attribute doesn't apply.  The only hints that Googling gave was making this change:  "Integrated Security=SSPI".  This did not change the error message.  At this point we set up numerous Scheduler tasks to try various combinations of attributes and values.  As it turns out, the "Integrated Security" attribute needed to be removed completely.

At this point we were able to successfully connect to our database via our VBScript with this connection string:

     Provider=SQLOLEDB.1;Data Source=209.200.235.3;Network Library=;Connection Timeout=2000;Packet Size=4096;
                          User ID=myUser;Password=myPassword;Encrypt=no;Initial Catalog=myDatabase;


We have not tried changing our Web.config file to reflect this different connection string.  Maybe at some point in the future, when we have nothing better to do, we will test this connection string.

Now we have some questions to help us understand a few things - and maybe to help others that come across this thread in the future.

Generically we can understand how two different programming languages might need different connection strings, especially since VBScript is considered to be older technology compared to .NET Framework.  So, even though both are Microsoft technologies, obviously there is something different about what they need - or what attributes/values are considered to be defaults or "expected".  The question becomes generically what is different about VBScript compared to ASP.NET (with Visual Basic code-behind) that would cause them to require different connection strings?

We created our MSSQL database and user in Plesk, and, myLittleAdmin shows us the connection string.  We can understand why that connection string would not include some default attributes such as "Provider".  But, we are a little confused as to why it would generate/specify the "Integrated Security=no" attribute - especially when it seems that the default value for "Integrated Security" works for VBScript.  So, one question is what is the difference between "Integrated Security=no" and leaving it out to basically implement the default value?  We are also confused as to why myLittleAdmin would create/generate a connection string that would include the "User ID" attribute, but, not include the "Password" attribute.  We understand from a security standpoint why they would not show the exact password value, but, why can't myLittelAdmin at least include something like "Password=**********;" in the connection string to indicate that it is required when the "User ID" attribute is specified?

Obviously the tech support employees at Lunarpages know what the default values for connection string attributes are for their SQL servers.  Since it would not "damage" the connection string to explicitly include attributes set to their default values, why doesn't myLittleAdmin include those attributes and their default values?  Not only would this explicitly tell us the value assigned to an attribute, but, we could also use those values as a learning tool to better understand connection strings.  Along those lines, to help people resolve these issues in the future, are the default values for connection string attributes displayed somewhere on the Lunarpages site?  Certainly Lunarpages might consider it a security risk to display those values to the public, but, wouldn't it be a simple/smart thing for Lunarpages tech support to include these default values in ANY/ALL help ticket "replies" to any question/issue that involves connection strings?

« Last Edit: August 10, 2011, 05:20:42 PM by Comet Software » Logged
cancy12
Space Explorer
***
Offline Offline

Posts: 6


« Reply #2 on: August 24, 2011, 11:56:46 PM »

We have successfully created the MSSQL database, captured the connection string as provided by myLittleAdmin (we did not see where it created a connection name aka DSN), and, ran several ASP.NET pages that have accessed the MSSQL database. Web hosting will help us solve many thing in our worked
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: