|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
help using forms to update mysql database
I'm trying to take in user input into textfeilds and input it into my MySQL database. Im using ASP. This is what I got, im not seeing and records appear in the database.
<% on error resume next dim adoConn dim strQuery set adoConn = Server.CreateObject("ADODB.Connection") adoConn.Open "Driver={mySQL}; Server=blah.com; Port=3306; Option=0; Socket=; Stmt=; Database=inventory; Uid=sa; Pwd=sa;" if adoConn.errors.count = 0 then response.write "<h2>connected</h2>" else response.write "ERROR: Couldn't connect to database" end if strQuery = "INSERT INTO computer(NAME) VALUES" dim strName %> <form action="inventory_form_jeremy.asp" onSubmit="<% adoConn.Execute strQuery %>" method="POST"> Name: <input type="text" name="name" id="name"> <% strName = Request.form("name") strQuery = strQuery & "('" & strName & "')" %> </form> My SQL statement works, only if I hardcode the statement after I connect to the database, not with the user input. That narrows it down to my execute query statement(I think) Any ideas? Thank you, Jeremy |
|
#2
|
||||
|
||||
|
If the query works when you hard code the line in and run, then the problem would appear to be in your use of ASP to build the query dynamically. I have moved this to the ASP forum, where you're more likely to get help with this code.
I would suggest that you construct the query, and then just display it on the screen to the user. You can then visually inspect it or cut and paste it into a mysql dialoge and get the full error message. christo
__________________
. Spiration channels: Free scripts, programming tutorials and articles Dotcut alerts: Online Press cuttings / news alerts Clearprop: UK microlight school, wiltshire Uk dating: UK safe dating with Topdates About Christo . . |
|
#3
|
||||
|
||||
|
So you don't get any error, but no records are inserted? Or are empty records inserted? Or do you get an error?
The way you have the form and handler setup is rather strange to me. What is the name of your form? Are you having the form submit to itself? I would separate the form (call it "myForm.asp" or something) from the form handler ("myHandler.asp"). Then take Code:
<form name ="myForm.asp" action="myHandler.asp" method="POST"> Name: <input type="text" name="name" id="name"> </form>
__________________
--Dave-- U2kgSG9jIExlZ2VyZSBTY2lzLCBOaW1pdW0gRXJ1ZGl0aW9uaXMgSGFiZXM= |
|
#4
|
|||
|
|||
|
Take out the "on error resume next" so you can see what errors you are getting. If you use IE also go to Tools - Internet Options - Advanced Options and uncheck the "show friendly http errors" setting.
Look around in this area of the manual for some examples of ADO usage of the MyODBC drivers. http://www.mysql.com/products/myodb...or_ODBC_With_VB You must install MyODBC on the web server. |
|
#5
|
|||
|
|||
|
I guess i could use two pages, one form and another handler. I was just trying to do it all in one shot. So when my handler is passed the form, how do I call back for the textfield variables? i guess thats an ASP question, i'll try the other form also.
|
|
#6
|
|||
|
|||
|
I am in the right form...haha
I have my two pages set up and the connection works, I just need to figure out how to reference those textfield variables from this page. Im not sure if its anything like PHP, where you go $_POST(variable). Thanks |
|
#7
|
||||
|
||||
|
To get your values from the form, you would do
Code:
dim myVariable
myVariable=Request.form("textfieldname")
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > help using forms to update mysql database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|