multiple query problem
- From: "J.J.Cale" <jimbo@xxxxxxxxxx>
- Date: Wed, 9 Apr 2008 07:21:31 -0700 (PDT)
Hi all
sql newbie here. The function below works as I expect on my computer,
XP IE6. i.e. I open a connection, open a recordset, fetch data, close
recordset, relplace query, open new recordset etc. Data is received
properly from both queries. BUT when I run this on another computer,
XP IE7 the BOF flag is true on the second recordset and I get "Sorry
no content" as output. I tried using a bookmark but wasn't sure what
to bookmark and don't understand the cursor style binding involved. I
also tried closing the connection and reopening it between queries but
BOF is still true on the second query. Is the problem IE version or
possibly different browser settings. Do I have to destroy the original
object and recreate? Anyone can tweak this for me or explain the
problem? TIA.
Jim
Watch out for workwrap in the sql queries. Don't forget to change
strDbPath ;>)
var adOpenDynamic = 2;
var adLockOptimistic = 3;
var strDbPath = "c:\\mypath\\mydb.mdb";
var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
strDbPath;
function getAdoDb(strAdoType) {
if (window.ActiveXObject) {
return new ActiveXObject(strAdoType);
}
else {
return new ActiveXObject(strAdoType);
}
}
var Currency = new Array();
var currTotal = new Array();
function showReports(){
try {
var strHtml ="";
strHtml += "<table cellspacing=0>";
strHtml += "<tr ><th>îëéøä</th><th>÷ðéä</th><th>éöéâ</th><th>îèáò</
th></tr>";
var conn = getAdoDb("ADODB.Connection");
conn.open(conn_str, "", "");
var rs = getAdoDb("ADODB.Recordset");
var strQuery = "SELECT CurrencyISO.CurrNameEngl AS name,
CurrencyISO.CurrencyISO AS iso, CountryISO.CountryEng AS country,
crc.bankRate, crc.saleRate, crc.buyRate, currency.view FROM crc INNER
JOIN (CountryISO INNER JOIN (CurrencyISO INNER JOIN [currency] ON
CurrencyISO.id = currency.nameID) ON CountryISO.ID =
currency.countryID) ON crc.CurrCode = currency.code WHERE
currency.view=True;";
rs.open(strQuery, conn, adOpenDynamic, adLockOptimistic);
if(!rs.bof) {
var ind = 0;
rs.MoveFirst();
while(!rs.eof) {
if (rs.fields(1).value == 'HKD') rs.MoveNext();
var per = 1;
var arr = new Array();
arr[0] = rs.fields(1).value;
if (arr[0] == 'JPY') per = 100;
arr[1] = (rs.fields(4).value * per).toFixed(4);
arr[2] = (rs.fields(5).value * per).toFixed(4);
arr[3] = (rs.fields(3).value * per).toFixed(4);
Currency[ind] = arr;
strHtml += "<tr>";
strHtml += " <td>" + arr[1] + "</td>";
strHtml += " <td>" + arr[2] + "</td>";
strHtml += " <td>" + arr[3] + "</td>";
strHtml += " <td style='text-align:right;font-weight:bold;'>" +
hebArray[ind] + "<img src='../flags/" + flagArray[ind] + "1.gif'
width=60 height=40 align='center' border='1'></td>";
strHtml += "</tr>";
ind++;
rs.MoveNext();
}
}
else {
strHtml += "<tr colspan=4><td style='text-align:center;'>àéï
îèáòåú</td></tr>";
}
strHtml += "</table>";
document.write(strHtml);
document.write('<div id="dateline">' + mydate + '</div>');
rs.close();
var strQuery = "SELECT CurrencyISO.CurrencyISO, [cashOperation].
[amount] FROM (CurrencyISO INNER JOIN [currency] ON CurrencyISO.id =
currency.nameID) INNER JOIN cashOperation ON [currency].
[code]=[cashOperation].[currencyCode]";
rs.open(strQuery, conn, adOpenDynamic, adLockOptimistic);
if(!rs.bof) {
var ind = 0;
rs.MoveFirst();
while(!rs.eof) {
var arr = new Array();
arr[0] = rs.fields(0).value;
arr[1] = rs.fields(1).value;
currTotal[ind] = arr;
ind++;
// document.write('<div>' + arr[0] + ' ' + arr[1] + '</div>');
rs.MoveNext();
}
}
else document.write('<div>Sorry no content</div>');
conn.close();
}
catch(ex) {
alert(ex.message);
}
}
.
- Follow-Ups:
- Re: multiple query problem
- From: Bob Barrows [MVP]
- Re: multiple query problem
- Prev by Date: Re: vb6/ADO 2.8/ DB2
- Next by Date: Re: multiple query problem
- Previous by thread: How to catch a zero net change in a DataSet before Adapter Update?
- Next by thread: Re: multiple query problem
- Index(es):
Relevant Pages
|
|