Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jmich
Starting Member
2 Posts |
Posted - 2004-06-18 : 05:37:57
|
Hi,I have a problem with resultsets from SQL server.The query is dead simple, like "Select * from [table]"Sometimes I experience that I cannot print out the result directly from the resultset, like:response.write res("column1")instead, I have to put the result in a variable end print out the variable:dim var1var1 = res("column1")response.write var1The other problem is that I have to access the columns of the resultset in the exact order in which they appear in the database, like:var1 = res("column1")var2 = res("column2")var3 = res("column3")var4 = res("column4")If I shuffle the lines:var3 = res("column3")var4 = res("column4")var1 = res("column1")var2 = res("column2")only var3 and var4 has values from the resultset while var1 and var2 are emptyMy connectstring isconnStr = "Driver={SQL Server};Server=[serverName];Database=[dbName];Uid=xxxx;Pwd=yyyy;"ideas anybody ? |
|
mr_mist
Grunnio
1870 Posts |
Posted - 2004-06-18 : 06:33:30
|
It may be due to the opening cursor type that you use, which only allows you to read the records in order.Personally, I would forget about reading records on an individual basis and do your operations like this...rs = blah.execute()your_data_array = rs.getrows()rs.closeThen all you have to do is parse the elements of your_data_array to get the records. You can manipulate them as many times as you like in whatever order because it is ASP side. It will also be faster.Have a search around www.4guysfromrolla.com or similar if you need more info on getrows()-------Moo. :) |
|
|
jmich
Starting Member
2 Posts |
Posted - 2004-06-18 : 07:27:30
|
Hi mr_mist,Thank you for replying.The problem is not that I have to read the records in order, but that I have to read the COLUMNS in order.The problem exist also when the select clause returns only 1 single record.After investigating further I found that the problem must be on my local webserver, since it works fine when I upload it and run it on my website (using same db both places). |
|
|
|
|
|