Striped Fish2 Posted May 21, 2011 Report Share Posted May 21, 2011 Okay I am working on a game and in my database there's accounts and there characters under each account. I use the Acc field to link that character with the id of an account. The problem is when creating a new character. The Acc field is a number field. And the ID variable (which is placed into the Acc field) is a string. I know this is got to be the problem because when I troubleshooted I tested ID=1 and that worked. But this has to work for everyone. So I need to know a function that converts a string to a number. After searching on the internet I found CInt but it didn't seem to work. I am using an access database. Here is my code <%set conn=Server.CreateObject("ADODB.Connection") conn.provider="Microsoft.Jet.OLEDB.4.0"conn.open "D:\Hosting\5230803\html\access_db\DragonKwest.mdb"name=Request.Querystring("name")race=Request.Querystring("race")gender=Request.Querystring("gender")stringID=Request.cookies("ID")ID=CInt(stringID)sql="INSERT INTO Characters ([Name],[Acc],Race,[Turns],[Gold],[lvl],Gender,[HP],Hitpoints,[num_of_kills],[Portrait],"sql=sql & "expierence,[XP],energypoints,[EP],att1,att2,[STR],[RAN],[H2H],[MGR],[DODGE],[PARRY],[ARMOUR],lsp,"sql=sql & "[equipaccessory],[Date_Registered],[last-logged],[equipbow],[equipsword])" sql=sql & " VALUES "sql=sql & "('" & name & "'," & ID & ",'" & race & "',50,200,1,'" & gender & "',25,25,0,'elf-male.png',"sql=sql & "0,20,10,10,'Strong Shot','Broad Attack',18,93,60,38,83,55,0,'dragoth/tutorial.asp',"sql=sql & "'empty',#" & NOW() & "#,#" & NOW() & "#,'empty','empty')"response.write sqlconn.Execute sqlif err<>0 then for each objErr in objConn.Errors response.write("<p>") response.write("Description: ") response.write(objErr.Description & "<br />") response.write("Help context: ") response.write(objErr.HelpContext & "<br />") response.write("Help file: ") response.write(objErr.HelpFile & "<br />") response.write("Native error: ") response.write(objErr.NativeError & "<br />") response.write("Error number: ") response.write(objErr.Number & "<br />") response.write("Error source: ") response.write(objErr.Source & "<br />") response.write("SQL state: ") response.write(objErr.SQLState & "<br />") response.write("</p>") nextelse Response.redirect("account.asp")end ifconn.close%> Link to comment Share on other sites More sharing options...
justsomeguy Posted May 22, 2011 Report Share Posted May 22, 2011 CInt, CLng, and CDbl will all convert an expression to a type of number. They do actually work. If you don't think they work, print out the value before and after you convert it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now