Striped Fish2 Posted July 23, 2010 Share Posted July 23, 2010 Okay I am trying to add some data to a MS Access database here is my code. <%'BeginBattle.asp Created Glorfindel on 7/20/2010'Retrieve Enemy listuser="Glorfindel"enemies=request.querystring("enemy")'Create database connectionset conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open "C:\inetpub\wwwroot\DragonKwest.mdb"'Create SQL based on the variable enemiesIf enemies="2goblins" thensql="INSERT INTO Combat (Player,numofenemies,Enemy1,Enemy2,Enemy1_health,Enemy2_health)"sql=sql & " VALUES "sql=sql & "('" & user & "',2,'Goblin','Goblin',10,10)"ElseIf enemies="1Archer" thennumofenemies=1enemy="Goblin Archer"End If'Execute SQLconn.Execute sqlconn.close%> When ever I run this script the page just displays a white page (like it should no error) but when I check there is no data added to the database. What am I doing wrong. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 23, 2010 Share Posted July 23, 2010 It's only going to insert if you gave "2goblins" as the value for the querystring variable "enemy". Is that how you're testing it? Link to comment Share on other sites More sharing options...
Striped Fish2 Posted July 23, 2010 Author Share Posted July 23, 2010 oh thanks, that fixed it. Link to comment Share on other sites More sharing options...
Striped Fish2 Posted July 23, 2010 Author Share Posted July 23, 2010 I have a similer problem except this time it is actually returning an error. Here is my code I think the error is being generated becasue I used a keyword in my SQL, but I don't know what word it is. <%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.Form("username")password=Request.Form("password")email=Request.Form("email")sql="INSERT INTO User_Accounts ([Name],Username,Password,Email,Developer,[Date_registered],[Date_last_logged],playnum)" sql=sql & " VALUES "sql=sql & "('Name','" & name & "','" & password & "','" & email & "','False',#" & NOW() & "#,#" & NOW() & "#,1)"on error resume nextconn.Execute sqlif err<>0 then Response.Write(sql)else Response.Redirect("Index.asp?error=%20You%20are%20now%20registered%20you%20can%20now%20login")end ifconn.close%> Link to comment Share on other sites More sharing options...
justsomeguy Posted July 23, 2010 Share Posted July 23, 2010 Sometimes password is a reserved word. The error message should indicate at least at which part of the query it found a problem. Link to comment Share on other sites More sharing options...
Striped Fish2 Posted July 23, 2010 Author Share Posted July 23, 2010 Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.