hi.
I am trying to set a dynamic website, and would like to add the facility whereby data can be entered via a form and inserted into a database table. I have attempted to do this. I have a form that prompts the user to enter the new barcode and supplier of stationary into the stationary table. I have tryed to do this with the following code, but the ODBC error displayed is Data source name not found and no default driver specified /updatestationery.asp, line 8.
My form page is:
<% @LANGUAGE = VBScript %>
<%
If Session("Username" = "noUser" Then
Response.Redirect("default.asp"
End If
%>
<html>
<head>
<title>Add stationery Item</title>
</head>
<body>
<p align="center">
<b><font face="Verdana" size="4">Add Stationery Item</font><font face="Verdana" size="3"><br>
</font></b>
<p align="center"><img border="0" src="images/stock.5.gif"><b><font face="Verdana" size="3">
<br>
</font></b></p>
<p align="center"> </p>
<table border="0" width="80%" height="149">
<tr>
<td width="36%" height="25" align="left" valign="middle">
<form ACTION="updatestationery.asp" METHOD="POST">
<font face="Verdana" size="3">Barcode:</font></td>
<td width="64%" height="25" align="left" valign="middle"><font size="1"><input SIZE="15" NAME="NewBBarcode"></font></td>
</tr>
<tr>
<td width="36%" height="25" align="left" valign="middle"><font face="Verdana" size="3">Supplier:
</font></td>
<td width="64%" height="25" align="left" valign="middle"><font size="1"><input SIZE="15" NAME="NewBSupplier"></font></td>
</tr>
<tr>
<td width="40%" height="63" align="center">
<p align="left"><input TYPE="SUBMIT" VALUE="Submit"></td>
<td width="60%" height="63" align="center">
<p align="left"> </FORM>
</td>
</tr>
</table>
</body>
</html>
The update stationary table, which is meant to insert the data into the table is as follows:
<% @LANGUAGE = VBScript %>
<%
Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection"
Dim ConnectionString
Conn.ConnectionString = "DSN=Tables; UID=; PWD="
Conn.Open ConnectionString
Set stationery = Server.CreateObject("ADODB.Recorset"
sSQL = "SELECT * from stationery"
stationery.Open, sSQL, Conn
Barcode = Request.Form("NewBBarcode"
If Len(Barcode) > 0 Then
Application.Lock
stationery.AddNew
stationery.Fields("Barcode" = Barcode
stationery.Fields("Supplier" = Request.Form(NewBSupplier)
stationery.UpdateBatch
Application.Unlock
Response.Redirect("success.asp"
ELSE Response.Redirect("fail.asp"
End If
Set objCmd = Nothing
objConn.Close
Set objConn = Nothing
%>
Can anyone figure out what is actually wrong with the code??! I would really, really, really appreciate it. Thanks.
I am trying to set a dynamic website, and would like to add the facility whereby data can be entered via a form and inserted into a database table. I have attempted to do this. I have a form that prompts the user to enter the new barcode and supplier of stationary into the stationary table. I have tryed to do this with the following code, but the ODBC error displayed is Data source name not found and no default driver specified /updatestationery.asp, line 8.
My form page is:
<% @LANGUAGE = VBScript %>
<%
If Session("Username" = "noUser" Then
Response.Redirect("default.asp"
End If
%>
<html>
<head>
<title>Add stationery Item</title>
</head>
<body>
<p align="center">
<b><font face="Verdana" size="4">Add Stationery Item</font><font face="Verdana" size="3"><br>
</font></b>
<p align="center"><img border="0" src="images/stock.5.gif"><b><font face="Verdana" size="3">
<br>
</font></b></p>
<p align="center"> </p>
<table border="0" width="80%" height="149">
<tr>
<td width="36%" height="25" align="left" valign="middle">
<form ACTION="updatestationery.asp" METHOD="POST">
<font face="Verdana" size="3">Barcode:</font></td>
<td width="64%" height="25" align="left" valign="middle"><font size="1"><input SIZE="15" NAME="NewBBarcode"></font></td>
</tr>
<tr>
<td width="36%" height="25" align="left" valign="middle"><font face="Verdana" size="3">Supplier:
</font></td>
<td width="64%" height="25" align="left" valign="middle"><font size="1"><input SIZE="15" NAME="NewBSupplier"></font></td>
</tr>
<tr>
<td width="40%" height="63" align="center">
<p align="left"><input TYPE="SUBMIT" VALUE="Submit"></td>
<td width="60%" height="63" align="center">
<p align="left"> </FORM>
</td>
</tr>
</table>
</body>
</html>
The update stationary table, which is meant to insert the data into the table is as follows:
<% @LANGUAGE = VBScript %>
<%
Dim Conn
Set Conn = Server.CreateObject("ADODB.Connection"
Dim ConnectionString
Conn.ConnectionString = "DSN=Tables; UID=; PWD="
Conn.Open ConnectionString
Set stationery = Server.CreateObject("ADODB.Recorset"
sSQL = "SELECT * from stationery"
stationery.Open, sSQL, Conn
Barcode = Request.Form("NewBBarcode"
If Len(Barcode) > 0 Then
Application.Lock
stationery.AddNew
stationery.Fields("Barcode" = Barcode
stationery.Fields("Supplier" = Request.Form(NewBSupplier)
stationery.UpdateBatch
Application.Unlock
Response.Redirect("success.asp"
ELSE Response.Redirect("fail.asp"
End If
Set objCmd = Nothing
objConn.Close
Set objConn = Nothing
%>
Can anyone figure out what is actually wrong with the code??! I would really, really, really appreciate it. Thanks.