Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP data into MySQL

Status
Not open for further replies.

bulb2005

Technical User
Feb 6, 2005
16
US
All,
I am new to all this, so please be patient with me. I have established a connection with my MySQL database using ASP, but now I want to get data into the database via an .asp form.

The connection code I have inside regForm.asp is:

<%

ConnString = "Driver={MySQL};SERVER=localhost;DATABASE=databasename;UID=uid;PASSWORD=password"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnString

%>

What do I need to do to have data populate the MySQL table when the submit button on the form is clicked?

I have replaced the actual real info in the code above with generic stuff.

Please help.

Thanks in advance,
 
You need to run a select statement to retrieve the data back into your code, from there you can do what you need to with it...

try starting here

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
first get some values out of your HTML form


Assuming you have two fields
<input type="text" name="name">
<input type="text" name="surname">

and a DB table called "contacts"
ID, name, surname

then in your ASP page

<%
dim f1, f2, strSQL
fName = request("name")
lName = request("surname")

strSQL = "insert into contacts(name, surname) values ('" & fName & "', '" & lName & "')

conn.execute strSQL
response.write("1 record inserted")

%>
My reply will get you started but I agree with Bastien though; w3schools is a perfect place to look for reference.

Bye

QatQat


Life is what happens when you are making other plans.
 
ah, damn, read the requirement backwards...

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top