Cannot Connect to New Database Server using ADO
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cannot Connect to New Database Server using ADO
I have created automation scripts that used an ADO command object to connect to our internal server's databases and make several select, update and insert statements, and that would run great.
We recently migrated to a new database server and now even with the proper edits to my connection string, I can't appear to connect to the database despite the connection string test being a success.
Here is an example of my code.
var Qry = ADO.CreateADOCommand();
var dbname = DatabaseName;
Qry["ConnectionString"] = "Provider=SQLOLEDB.1;Password=pw;Persist Security Info=True;User ID=SQLServerUsr;Initial Catalog=dbname;Data Source=Servername";
for(var i = 1; i <= rowcount; i++) {
var testcell = VarToStr(xlsheet.Cells(i+1, 61).Value);
Log.Message(testcell);
tags[i] = testcell;
Qry["CommandText"] = "SELECT catalogid FROM oproducts WHERE oproducts.cname = '" + prodnamesarray[i] + "'"
Qry.CommandType = cmdText;
var catalognum = Qry["Execute"]();
prodids[i] = catalognum.Fields.Item("catalogid").Value;
}
for(var j = 1; j < rowcount; j++) {
if(tags[j] != "") {
Qry["CommandText"] = "INSERT INTO MenuTagProductMap (MenuTagID, MenuProductID, EnteredDate) VALUES('" + tags[j] + "', '" + prodids[j] + "', GETDATE())";
Qry.CommandType = cmdText;
}
}
I also made my connection string by using the stores object in testcomplete to connect to my database initially.
I was made aware of permission changes on the new server, but I have had my test user given the proper permissions, but it doesn't appear to be connecting still, anyone have any ideas as to why this may be?
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The error occurs on the first instance of calling Qry[Execute], so the first loop where I call SELECT.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Creating the ADO Connection object seems to be redundant code, as you are just setting the Command Objects Connection String to the Connection object, and calling Execute opens the connection with the connection string set in the Command Object.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Afraid using the connection object caused a log in prompt to appear when trying to connect even with the user info in the connection string.
It also caused an error I could not exit from, as a pop up window saying the thread was not synchronized would not close.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not certain, at this point, what the next step is. It seems that something within the permissions are blowing up.
Do you have access to the server side logs? Is there a way you can find out whether or not the server is receiving the correct information. Also, try writing out the connection string to the test log to make sure that nothing is getting sent improperly.
Perhaps someone else may have another direction to try.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was able to figure out the root cause of the issue with some help.
Turns out TestComplete likes to leave out "\" in strings, so putting \\ in my connection string got me connected properly.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FYI, that leaving out of the \ I'd actually a function of the language you are using. In some of the languages supported by TestComplete, that symbol is used to mark a special character like \' to actually print the single quote rather than terminate a string. So, to tell TC to actually include the \ character you need to double it up. I should have caught that in your earlier example.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just also make my connection string to '\\' and it works!

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »