Hi,
Iam haven some problem with my code.
All I want to do is open up connect to database and insert data after button on the page has been clicked. Right now it doesnt execute unless I remove |"If Len(Request.Form("form1")) > 0 Then" and "End If" then when page is loaded it insert data which is good but not really because I then I get bad data because no one had selected anything in the form and to solve my delima I just want the code to be executed after button has been click.
Everything I do just wont work... there is input button that has name="image3222" and when the button is click if statement should fire but it doesnt.
I cant see whats wrong so maybe someone on this forums can get me in the right direction.
Thanks
<input type="image" src="../Images/submit_radio.gif" width="70" height="25" border="0" name="image3222" align="right">
<%
If Len(Request.Form("image3222")) > 0 Then
Dim sServer
Dim sLoginID
Dim sPassword
Dim sDate
Dim cn
'Get the Server and Login information
sServer = "xxxxxxxxxx
sLogin = "xxxxxxx"
sPassword = "xxxxxxxxx"
sDate = Now()
'Create a connection object
Set cn = Server.CreateObject("ADODB.Connection")
'Open a connection; the string refers to the DSN
cn.ConnectionString = "provider=sqloledb;SERVER=" & sServer & ";USER ID=" & sLogin & ";PWD=" & sPassword & ";DATABASE=Reservation"
cn.Open
sql="INSERT INTO searchResults (Type,SearchCity,"
sql=sql & "SearchCIDate,SearchCODate,SearchRooms,SearchUserName,SearchUserID,SearchTimeStamp)"
sql=sql & " VALUES "
sql=sql & "('" & 20 & "',"
sql=sql & "'" & (dictHotelReservationProfile("HotelCity")) & "',"
sql=sql & "'" & cDate(dictHotelReservationProfile("CIDate")) & "',"
sql=sql & "'" & cDate(dictHotelReservationProfile("CODate")) & "',"
sql=sql & "'" & dictHotelReservationProfile("NumberRooms") & "',"
sql=sql & "'" & Session("Username") & "',"
sql=sql & "'" & Session("UserID") & "',"
sql=sql & "'" & sDate & "')"
on error resume next
cn.Execute sql
if err<>0 then
end if
cn.close
Set cn = Nothing
end if
%>
Iam haven some problem with my code.
All I want to do is open up connect to database and insert data after button on the page has been clicked. Right now it doesnt execute unless I remove |"If Len(Request.Form("form1")) > 0 Then" and "End If" then when page is loaded it insert data which is good but not really because I then I get bad data because no one had selected anything in the form and to solve my delima I just want the code to be executed after button has been click.
Everything I do just wont work... there is input button that has name="image3222" and when the button is click if statement should fire but it doesnt.
I cant see whats wrong so maybe someone on this forums can get me in the right direction.
Thanks
<input type="image" src="../Images/submit_radio.gif" width="70" height="25" border="0" name="image3222" align="right">
<%
If Len(Request.Form("image3222")) > 0 Then
Dim sServer
Dim sLoginID
Dim sPassword
Dim sDate
Dim cn
'Get the Server and Login information
sServer = "xxxxxxxxxx
sLogin = "xxxxxxx"
sPassword = "xxxxxxxxx"
sDate = Now()
'Create a connection object
Set cn = Server.CreateObject("ADODB.Connection")
'Open a connection; the string refers to the DSN
cn.ConnectionString = "provider=sqloledb;SERVER=" & sServer & ";USER ID=" & sLogin & ";PWD=" & sPassword & ";DATABASE=Reservation"
cn.Open
sql="INSERT INTO searchResults (Type,SearchCity,"
sql=sql & "SearchCIDate,SearchCODate,SearchRooms,SearchUserName,SearchUserID,SearchTimeStamp)"
sql=sql & " VALUES "
sql=sql & "('" & 20 & "',"
sql=sql & "'" & (dictHotelReservationProfile("HotelCity")) & "',"
sql=sql & "'" & cDate(dictHotelReservationProfile("CIDate")) & "',"
sql=sql & "'" & cDate(dictHotelReservationProfile("CODate")) & "',"
sql=sql & "'" & dictHotelReservationProfile("NumberRooms") & "',"
sql=sql & "'" & Session("Username") & "',"
sql=sql & "'" & Session("UserID") & "',"
sql=sql & "'" & sDate & "')"
on error resume next
cn.Execute sql
if err<>0 then
end if
cn.close
Set cn = Nothing
end if
%>