all groups > sql server msde > may 2007 >
You're in the

sql server msde

group:

Sql 2000 script generates error on SQL2005



Sql 2000 script generates error on SQL2005 Claus
5/30/2007 11:16:44 PM
sql server msde: Hi all,

I wonder if someone could explain to me why the script below runs fine
against an SQL2000 server but fails with:
invalid object name 'People'. against an SQL2005 server.

The connection to the database works fine. If I supply the wrong password I
get a login error message.

Here is the script:

strFirstName = inputbox("Please type User FIRST Name:")
strLastName = inputbox("Please type User LAST Name:")
strInitials = inputbox("Please type User Initials:")

strFirstName = replace(strFirstName, "'", "''")
strLastName = replace(strLastName, "'", "''")
strInitials = replace(strInitials, "'", "''")

Set objConn = CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=TEST;UID=sa;password=123456"
objConn.Open

Set objRs = CreateObject("ADODB.Recordset")
objRs.CursorLocation = 3

strSQL = "Select Id FROM People WHERE FirstName = '" & strFirstName & "'
AND LastName = '" & strLastName & "' AND Initials = '" & strInitials & "'"

objRs.Open strSQL, objConn, 3, 4, 1

if objRs.RecordCount > 1 then
Msgbox "Error : More than one match found for the person you typed!"
elseif objRs.RecordCount <= 0 then
Msgbox "Error : No match found for the person you typed!"
elseif objRs("Id") = 0 then
Msgbox "Error : No match found for the person you typed!"
else
strPeopleId = cstr(objRs("Id"))

Msgbox "The person Id is "&strPeopleId
end if


TIA,
--
Claus

Re: Sql 2000 script generates error on SQL2005 Claus
5/30/2007 11:20:22 PM
Sorry, just noticed that I posted this in the wrong group.

--
Claus
[quoted text, click to view]

AddThis Social Bookmark Button