Jump to content

Adding data to database


Striped Fish2

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...