Link to home
Start Free TrialLog in
Avatar of Mark Lewis
Mark Lewis

asked on

Problem with random characters submitting to an Access DB

I am using a simple web based form to submit information to an Access DB. Here is a sample of the code:

<%
Dim myConnString
Dim myConnection
Dim mySQL

myConnString = Application("MyDBTable_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString
      
mySQL= "INSERT INTO Table "
mySQL= mySQL & "(status,pub_status,...
mySQL= mySQL & Request.Form("pub_status") & "','"
...

myConnection.Execute mySQL
myConnection.Close
Set myConnection = Nothing

If draft = "No" Then
...

The problem I am noticing is that every once in a while, random characters are appearing in the DB. For example the field called draft...I give the user to dropdown box to choose Yes as the box defaults to No. There's no way to specify anything besides Yes or No and as you can see from the code, I have condition statement based on which they choose. Well something happen three straight times to this users information and when I looked at the database the entry that was submitted was "Not". How did Not get into the field when the only two options were Yes or No?

I started looking around and another one of my fields which identifies which city our office was located, in this case Columbia, had entries like Columbial, ColumbiaR, Columbiae and my favorite Columbia&#10642%. This is a drop down as well. Any idea why or how these random character are getting added to the data entered.

BTW, this is a random occurrence, it does happen all the time, just occasionally and it just started happening in the last week or so.

Thanks
Avatar of PatHartman
PatHartman
Flag of United States of America image

You cut off the code so we really can't tell what it is doing.  One general suggestion that might help is  to check for Yes rather than No.  If this is a drop box and nothing is selected, what is causing the default value to be populated and when?  It might actually be null and your code would assume that null is actually yes and since I can't see the rest of the code, this could be your problem.  Also, and this is really stretching since I know nothing about ASP and I haven't done CICS work in years  when I was developing CICS transactions with COBOL, if I didn't initialize a variable, it might contain whatever value was left in that byte by the last program that used that particular part of memory.  If ASP works that way, that could be the problem.  Most of the time the app loads into a location that is cleared but not always.  Some languages such as VBA protect us from this by initializing all variables.
Avatar of Mark Lewis
Mark Lewis

ASKER

I dont think there's an issue with the code as it's been working correctly for years. I suspect more of an issue with the database or maybe even IIS? not sure.. thats the reason I didnt list all the code. The dropdowns defaults to No and always has but for some reason, the value of "No" gets entered into the DB as "Not". Same thing seems to be happening with my office field. And again, this is random. My users probably submit 20-30 forms a day and it will do this every 3 or 4 days so only about 2% of the time and the user is random as well.
If the default is on the table, the default value does not get populated until the record is saved and ONLY if the inserted value is Null.

Do you understand the logic error of checking for No if the default is being done at the table level?
ASKER CERTIFIED SOLUTION
Avatar of Mark Lewis
Mark Lewis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial