guys i have a html form that has action to redirect it to asp page,, dat asp page has vb script that recieves values from the form and add it to access db..out of those i hav two textboxes for which i have to keep a constant value.. but when i execute it,,it gives me error..how can i do it without manually entering values for dose 2 fields.. i want vbscript here is what i have those two fields are itemid and price..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<%
' Declaring variables
Dim name, email, country, itemcode,price, data_source, con, sql_insert
' A Function to check if some field entered by user is empty
Function ChkString(strin g)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
name = ChkString(Reque st.Form("name") )
email = ChkString(Reque st.Form("email" ))
country = ChkString(Reque st.Form("countr y"))
itemcode = ChkString(Reque st.Form("itemid "))
price = ChkString(Reque st.Form("price" ))
data_source = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" & _
Server.MapPath( "form.mdb")
sql_insert = "insert into users (name, email, country, itemid, price) values ('" & _
name & "', '" & email & "', '" & country & "' , '" & itemid & "' , '" & price & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateOb ject("ADODB.Con nection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
Response.Write "All records were successfully entered into the database."
%>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<%
' Declaring variables
Dim name, email, country, itemcode,price, data_source, con, sql_insert
' A Function to check if some field entered by user is empty
Function ChkString(strin g)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function
' Receiving values from Form
name = ChkString(Reque st.Form("name") )
email = ChkString(Reque st.Form("email" ))
country = ChkString(Reque st.Form("countr y"))
itemcode = ChkString(Reque st.Form("itemid "))
price = ChkString(Reque st.Form("price" ))
data_source = "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" & _
Server.MapPath( "form.mdb")
sql_insert = "insert into users (name, email, country, itemid, price) values ('" & _
name & "', '" & email & "', '" & country & "' , '" & itemid & "' , '" & price & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateOb ject("ADODB.Con nection")
con.Open data_source
con.Execute sql_insert
' Done. Close the connection
con.Close
Set con = Nothing
Response.Write "All records were successfully entered into the database."
%>
</body>
</html>
Comment