Problem with testing asp mysql variables

I have a problem that just started after I reinstalled my site server.

In the past, I could do this:

code:

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

      

check if it is empty or something else

code:

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

      

and if I could do anything with it (for example, show its value)

code:

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

      

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

code:

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

      

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

code:

<% if scrollername <> "" then %>

      

and show it too.

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

      

I would just like to go back to being able to perform operations on mysql recordset variables like b4 ....

Has anyone faced this problem? what changed, is it a fake mysql varsion or something else?

Thanks guys.

+1


source to share


6 answers


There are two things you must do to make sure you have a value in the field:

  • Make sure the recordset is not empty.
  • Make sure the field in the current value is not null.


I don't rule out driver changes that affected your code, but I suppose the difference is that your string actually returns an empty string (which will be ") and your recordset returns the correct NULL value (which is not" " )

+1


source


I've never seen this issue before, and I'm not sure why (more details on the error would be helpful), but as a relatively quick fix, you might want to discard the item when you use it. How:

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

      

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



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

Also, "after I reinstalled my site server" do you mean you did a clean install of the server OS? or did you just reinstall MySQL? Or something different? MySQL 5.1 just came out on December 8th - was that part of an update?

Finally, check out some of the comments on your question and some of your answers. All things being equal, if there is any clarification, edit the question to add details. Don't write an answer. This is not a forum, and you will reply that you will lose your context as soon as something has voted on it. It's also easier to grab the whole problem if it's all in one place, as opposed to scrolling between the question and the various appendices that represent the answers.

0


source


More details:

my odbc: mysql driver 5.1.

my mysql version: mysql server 5.0

my connetion string:

I tried to remove STMT = SET CHARACTER SET Hebrew; OPTION = 3; part - no change ...

the problem is using any variables directly from db, it can be any variable (text, date, int) ...

even

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

and th funny this ... it was all used to work just fine .. b4 setup

do you see something unusual? maybe a different mysql / ODBC version?

0


source


Ok ...

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

  • Yes. I installed the OS again (Windows Server 2003) on my webserver and installed mysql 5.0 server on it.

  • I don't get the error, it just doesn't return any data when I use the method I explained abourt and I have to use additional variables as I explained.

Need more details?

0


source


This might be the best way to check to check if the recordset is empty alternative way.

I usually 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

      

It might help to debug it in some way.

Oh, and something that might be important. I can't remember what caused this, but sometimes I found that when accessing MySQL fields through a recordset, it was always lowercase, no matter what fields are in the database definition or query.

If that doesn't crash your script, then try to figure out what was returned by the recordset.

Dim i

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

      

Good luck.

0


source


I have the same problem ... Just migrate the asp site from mysql 4 and odbc 3.x (old version ...) to mysql 5.1 and odbc 5.1. If I try this simple code:

set rs = conn.execute ("select ....") and not rs.eof response.write "t1:" and rs ("text") and "
t2:" and rs ("text") and "
", rs.MoveNext Vend

as an output, I get this: t1: hello t2: t1: how do you t2: etc ...

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

0


source







All Articles