tags:

views:

390

answers:

6

Hi everyone.

I have a problem that just started happening after I reinstalled my website's server.

In the past I could do do this:

Code:

<% 
set msgSet = conn.execute("select * from base_scroller where scroller_num = 1" 
%>

check if it's not empty or anything else

Code:

<% if msgSet("scroller_name") <> "" then %>

and if it is i could do anything with it (like showing it's value)

Code:

<%= msgSet("scroller_name") %>
<% end if %>

Now I can't do this, the "if" test doesn't work with the "msgSet("scroller_name")" and I have to redifine it first in another variable

Code:

<% scrollername = msgSet("scroller_name") %>

then and only then I can do tests on it...

Code:

<% if scrollername <> "" then %>

and show it too.

<%= scrollername %>
<% end if %>

I would just like to get back the option to do the operations on the mysql recordset variables like b4....

Has someone come across this problem ? what has changed, is it a falty mysql varsion or something ?

Thank you guys.

A: 

Never seen that problem before, nor am I sure why (more information on the error would be helpful) - but, as a relatively quick fix you may want to cast the item when you use it. Like:

   <%= cStr(msgSet("scroller_name")) %>

See http://www.w3schools.com/vbscript/vbscript_ref_functions.asp#conversion for more information.

More information about the error you are getting would help you get a better answer. There is no MyODBC 5.1, so which version of the MyODBC drivers are you using? By "my odbc is: mysql 5.1 driver" you mean the driver for MySQL 5.1 - that should be MyODBC version 3.51.

Also, by "after I reinstalled my website's server" do you mean you did a clean install of the server OS? or did you just re-install MySQL? Or something else? MySQL 5.1 just came out 8 Dec. - was this part of an upgrade?

Lastly, please read some of the comments to your question and some of your replies. All things being equal, if there is some clarification needed, edit the question to add the details. Don't write a response. This isn't a forum, and you're response will lose its context the minute something is up-voted above it. Also its easier to take in the entire issue if its all in one spot as opposed to scrolling between the question and the various addendums posing as replies.

AnonJr
A: 

More details:

my odbc is: mysql 5.1 driver.

my mysql version : mysql server 5.0

my connetion string is:

<% strConnection="DRIVER={MySQL ODBC 5.1 Driver};SERVER=mysql.base.co.il;DATABASE=base_2005 ;USER=norrik;PASSWORD=yossik;STMT=SET CHARACTER SET hebrew;OPTION=3;" Set conn = Server.CreateObject("ADODB.Connection") conn.Open strConnection %>

I've tried to remove the STMT=SET CHARACTER SET hebrew;OPTION=3; part - no change...

the problem is using any variables right from the db, it could be any kind of variable (text,date,int)...

even

day(msgSet("scroller_date")) doesn't work now...

and th funny this is... it all used to work just fine.. b4 the installation

you see anything out of the ordinary ? maybe a different mysql/ODBC version ?

FYI: This site isn't like forums - you'll do better to edit the question than to post a reply like this. Also, I hope that's a fake user name, password, server address, etc. - otherwise you're going to want to change at least the user name and password now.
AnonJr
Also, it would really help to answer the two questions in the comments...
AnonJr
A: 

Ok...

  1. the new odbc is 5.1 : located on the mysql.com servers (link: http://dev.mysql.com/downloads/connector/odbc/5.1.html)

  2. Yes. I've reinstalled the OS (windows server 2003) again on my webserver and installed mysql server 5.0 on it.

  3. I'm not getting an error,it is just not returning any data when I use the method I was explaining abourt, and I have to use the extra variables like I explained.

Do you require anymore details please ?

A: 

It could be a better way to test to check to see if the recordset is empty in an alternative manner.

I generally use:

On Error Goto 0

set msgSet = conn.execute("select * from base_scroller where scroller_num = 1" 

If msgSet.EOF = True And msgSet.BOF = True Then
  Response.Write "Recordset cursor was at the beginning and end of file - empty set."
  Response.End
End If

This might help some way towards debugging it.

Oh, and something that might be important. I can't remember what caused it, but sometimes I found that when referencing MySQL fields via a recordset, it was always lower case, regardless of what the fields are in the database definition or query.

If this doesn't cause your script to fail, maybe try finding out what has been returned by the recordset.

Dim i

For Each i In msgSet.Fields
  Response.Write i & "=[" & msgSet.Fields(i) & "]<br />"
Next

Good luck

Amadiere
+1  A: 

There are two things you should do to ensure you have a value in a field:

  1. Make sure the recordset is not empty.
  2. Make sure the field in the current does not have a NULL value.

<% if NOT msgset.EOF then if msgset("scrollername") = Null Then response.write msgset("scrollername") else response.write "Scroller has no value" end if else response.write "no matching entires in the database" end if %>

I am not away of any changes in the drivers that have affected your code, but I assume the difference is that your string actually returns an empty string (which would equal "") and your recordset is returning a proper NULL value (which is not equal "")

Espen
A: 

I'm getting the same problem... Just migrating an asp site from mysql 4 & odbc 3.x (an old version...) to mysql 5.1 and odbc 5.1 . If i try this simple code :

set rs = conn.execute("select ....") while not rs.eof response.write "t1 : " & rs("text") & "
t2 : " & rs("text") & "
" rs.movenext wend

as output i get the following : t1 : hello t2 : t1 : how are you t2 : etc...

The second time I access the field it has no value, the only way is to use a temp variable to store the data the first time...