Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check record database in javascript

Status
Not open for further replies.

cat5ive

MIS
Joined
Dec 3, 2004
Messages
184
Location
US
Hi,

I try to query to check if record exist. I copied the code that I used in vbscript and tried to modify in javascript. When I run my asp page, I got error message "missing ')'" and it pointed to the statement that I color in red.

Please help.

Code:
<script type="text/javascript" defer>
  <!--
function check_input()
{  

      var objconn = Server.CreateObject("ADODB.Connection")
[COLOR=red]
      objconn.Open(DSN=as400DSN, database=172.16.1.10, uid=NO, pwd=XXXX, " ")[/color]
       var rsMVAPH = Server.CreateObject("ADODB.Recordset")
           var sql = "SELECT phinv# FROM cisdtalib.$mvaph where phinv#='"&strinvnumber&"'"
       rsMVAPH.Open(sql, objconn,1,1)
       if (not rsMVAPH.eof)
	   {document.write ("found");
	    }
	else
           {document.write("no");
	   }
	   document.end 
}
  -->
	</script>
 
Do you mean like this?
Code:
objconn.Open(DSN="as400DSN", database="172.16.1.10", uid="NO", pwd="XXXX", " ");
I still got the same error.

Thanks
 
You'll have a problem with this statement:
Code:
var sql = "SELECT phinv# FROM cisdtalib.$mvaph where phinv#='"&strinvnumber&"'"

because Javascript uses the plus sign to concatenate strings, not the ampersand like VBScript.

And I think BRPS meant
Code:
objconn.Open("DSN=as400DSN", "database=172.16.1.10", "uid=NO", "pwd=XXXX", " ");

but figure he'll correct this if it's wrong.

Lee
 
No - ALL your strings must have quotes around them, not just half of them. If the "Open" call takes one big string parameter, then put quotes around the whole lot:

Code:
objconn.Open('DSN=as400DSN, database=172.16.1.10, uid=NO, pwd=XXXX, " "');

If it takes separate parameters, then put quotes around each:

Code:
objconn.Open('DSN=as400DSN', 'database=172.16.1.10', 'uid=NO', 'pwd=XXXX', " ");

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi,

I tried both, still get same message (missing ')').
Code:
 objconn.Open('DSN=as400DSN', 'database=172.16.1.10', 'uid=NO', 'pwd=XXXX', " ");

or

objconn.Open('DSN=as400DSN, database=172.16.1.10, uid=NO, pwd=XXXX, " "');

Thanks
 
Other variations maybe?
Code:
objconn.Open("'DSN=as400DSN', 'database=172.16.1.10', 'uid=NO', 'pwd=XXXX', ' '");

or

Code:
objconn.Open("DSN='as400DSN'", "database='172.16.1.10'", "uid='NO'", "pwd=XXXX'", " ");

Lee
 
No luck, same message.

Thanks
 
Are you guys missing this or is there a difference in server-side javascript I am not familiar with?
Code:
 if ([b][COLOR=red]not[/color][/b] rsMVAPH.eof)

It's hard to think outside the box when I'm trapped in a cubicle.
 
That's also an error, yes - along with this line, too:

Code:
 document.end

I suspect that that shold either not be present at all, or should have brackets after it:

Code:
 document.end)();

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top