validate your sql statement with a Response.Write to verify you have it correct before the sql is executed.
navin wrote on Sat, 13 Oct 2007 06:57:28 -0700:
> Hi 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:
Are you sure you're using that code? It's missing some <% and %> tags so
won't compile, let alone run. More comments inline, including the reason why
it inserts blank rows.
> 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
This part of the logic never gets run, because you set it to True earlier
and didn't set Validate_Form to False in your little validation check above.
So the next bit always runs, even if weekTitle or weekPath are blank ...
> Else
> strSQL = ""
> strSQL = strSQL & "INSERT INTO metricsLink "
[quoted text clipped - 7 lines]
> strSQL = strSQL & "'Metrics Wk " & weekname & "'"
> strSQL = strSQL & ");"
> RSConn.CursorType=2
> RSConn.LockType=3
> RSConn.Open strSQL,DBConn
> DBConn.Close
> Set DBConn = Nothing
When you request the page, the weekTitle and weekPath values are blank
(because you don't have those form variables filled in), and there's no
validation (you just force the validation variable value to True and never
change it), so voila! you get a blank row inserted.

Signature
Dan