Jump to content

Converting a string to number


Recommended Posts

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...