|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Stop blank lines...
hey all!
i wanna stop having blank lines being inserted into my database wen the page is refreshed... this is the following code: Code:
<%
Dim conn
Dim RS
idNumber = Request.Form("text1")
idNumber = CInt(idNumber)
%>
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Mode = adModeReadWrite
conn.open "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & Server.MapPath("../../Special/chelsea.mdb")
sql = "SELECT * FROM [team]"
Set RS = Server.CreateObject ("ADODB.Recordset")
RS.Open sql, conn, 3, 3
RS.AddNew
RS ("jerseyNos") = Request.Form("Text2")
RS ("fname") = Request.Form("Text3")
RS ("sname") = Request.Form("Text4")
RS ("position") = Request.Form("Text5")
RS.Update
%>
can someone add to it please? thanks in advance... Bhups |
|
#2
|
||||
|
||||
|
try checking to make sure the fields aren't empty first.
Code:
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Mode = adModeReadWrite
conn.open "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & Server.MapPath("../../Special/chelsea.mdb")
sql = "SELECT * FROM [team]"
Set RS = Server.CreateObject ("ADODB.Recordset")
RS.Open sql, conn, 3, 3
If(Request.Form("Text2") = "") Then
'Throw an error
Else If(Request.Form("Text3") = "") Then
'Throw an error
Else If(Request.Form("Text4") = "") Then
'Throw an error
Else If(Request.Form("Text5") = "") Then
'Throw and Error
Else
RS.AddNew
RS ("jerseyNos") = Request.Form("Text2")
RS ("fname") = Request.Form("Text3")
RS ("sname") = Request.Form("Text4")
RS ("position") = Request.Form("Text5")
RS.Update
End If
%>
|
|
#3
|
||||
|
||||
|
cheers mate...
is there n e way i can add the add code to a button so when it gets clicked it updates and adds the data to the db? i tried it this way but no good... Code:
<SCRIPT LANGUAGE=ASP/VBSCRIPT>
function AddArtsEvent()
RS.AddNew
RS ("jerseyNos") = Request.Form("Text2")
RS ("fname") = Request.Form("Text3")
RS ("sname") = Request.Form("Text4")
RS ("position") = Request.Form("Text5")
RS.Update
document.frm1.submit
end function
</SCRIPT>
<FORM NAME="frm1" METHOD="POST" ACTION="formAdd.asp">
<BR>
Jersey Nos: <BR> <INPUT NAME="Text2" SIZE="48">
<BR>
First Name: <BR> <INPUT NAME="Text3" SIZE="48">
<BR>
Second Name: <BR> <INPUT NAME="Text4" SIZE="48">
<BR>
Position: <BR> <INPUT NAME="Text5" SIZE="48">
<BR>
<INPUT TYPE=BUTTON VALUE="Submit" onclick="AddArtsEvent()">
</FORM>
thanks in advance... Bhups |
|
#4
|
||||
|
||||
|
not to worry... got it
![]() Code:
if Request.form("action")="send" then
RS.AddNew
RS ("jerseyNos") = Request.Form("Text2")
RS ("fname") = Request.Form("Text3")
RS ("sname") = Request.Form("Text4")
RS ("position") = Request.Form("Text5")
RS.Update
End if
|
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Stop blank lines... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|