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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I create a recordset to sql from javascript

Status
Not open for further replies.

countrygirl35

Programmer
May 13, 2008
4
0
0
US
I'm trying to create a recordset that goes out to an sql database and checks to see if a record exists. I've researched and cannot find a syntax that works correctly.
Any ideas?

<script type="text/javascript">
function movenext(){

var strzip=document.getElementById("Zip");

var cn = new ActiveXObject("ADODB.Connection");
var strConn = "FILEDSN=D:\Inetpub\DSN\sale.dsn";

cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");
var SQL = "SELECT * FROM IVRADM.T_SALES_LKP_Sales_Region WHERE Zip_Code = strzip ";

rs.Open(SQL, cn,2,3);

if(rs.eof){
alert("zipnotcorrect");
}
}
</script>
 
What's the problem with the code you've posted? What else have you tried? You say you've researched - have you tried google? I found many solutions when I did a simple search there.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
This is what I've used in the past... Note: it's *very* old code, and I've not done ASP/JS for years, so it may well all be outdated - but it might help.

Code:
var SQLstr = "SELECT * FROM tableName;";

var rs = Server.CreateObject("ADODB.Recordset");
rs.CursorType = 3;
rs.LockType = 2;
rs.Open(SQLstr, cn);

while (!rs.EOF) {
	// Do something
	rs.MoveNext();
}

// close the recordset
rs.Close();
rs = null;

You just have to make sure you've already "cn" defined and open.

If you're trying to do this client-side, I've no idea if it will work or not.

Hope this helps,
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