Page inserting blank
am 13.10.2007 15:57:28 von navinHi All,
i am trying to insert some records through ASP. In order to insert new
record, i have a link "Add New". Problem is when i click on link "Add
New" and go back to the view page, without saving any data, my page
still inserts blank data into the database. i am using the below code:
<%
' *** Begin DB Setup ***
Dim strConnString
Dim RSConn
Dim DBConn
' Sample access OLEDB CONN String.
'strConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
' Server.MapPath("acsdata.mdb") & ";"
Dim strDBPath
strDBPath=Server.MapPath("acsdata.mdb")
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strDBPath & ";"
Set RSConn=Server.CreateObject("ADODB.Recordset")
Dim strSQL ' String in which to build our SQL command
Dim weekTitle ' Title
Dim weekPath ' Path
Dim weekName ' Week
Dim Validate_Form
Dim msg_Disp
'If Request.Form("action") <> "Save Form Data" Then
' Response.Redirect("hps_supp_add.html")
' Show the form
weekTitle = Trim(Request.Form("mtitle"))
weekPath = Trim(Request.Form("mpath"))
weekname = Trim(Request.Form("mWeek"))
Validate_Form=true
If weekTitle = "" or weekPath = "" Then
msg_disp="AAA"
end if
IF NOT Validate_Form THEN
%>
<% Response.Write(msg_Disp)
%>
<%
Else
strSQL = ""
strSQL = strSQL & "INSERT INTO metricsLink "
strSQL = strSQL & "(metricsTitle, metricsPath, metricsWeek) " &
vbCrLf
strSQL = strSQL & "VALUES ("
strSQL = strSQL & "'" & weekTitle & "'"
strSQL = strSQL & ", "
strSQL = strSQL & "'" & weekPath & "\'"
strSQL = strSQL & ", "
strSQL = strSQL & "'Metrics Wk " & weekname & "'"
strSQL = strSQL & ");"
RSConn.CursorType=2
RSConn.LockType=3
RSConn.Open strSQL,DBConn
DBConn.Close
Set DBConn = Nothing
' Display a verification message and we're done!
End IF
%>