putting values from database into a drop down list - asp-classic

my tool is in asp. i am using this code for a query in sql
dim req_id
req_id=Request.Form("Req_id")
if req_id<>"" then
Set conn=server.CreateObject("adodb.connection")
conn.Open session("Psrconnect")
Set rs=CreateObject("Adodb.Recordset")
rs.Open "select * from passwords where REQ_ID='"&req_id&"'", conn
i want to put the results of this query into a drop down list. how do i do it? any help is very much appreciated.

Slightly edited code from my working pages :
function HtmlFormOption( byval psReturnValue, byval psDisplayValue ,byval psCurrentDefault)
dim x
if IsNull(psCurrentDefault) then psCurrentDefault = ""
if IsNull(psReturnValue) then psReturnValue = ""
if lCase( cStr(psReturnValue) ) = lCase( cStr(psCurrentDefault)) then
x = "selected "
else
x = ""
end if
HtmlFormOption = "<option " & x & "value='" & psReturnValue & "'>" & psDisplayValue & "</option>"
end function
dim Result, sCode, sWaarde
Result = "<select name='NameCombobox' size='1'>" & vbCrlf
while not objRecLookup.Eof
sCode = objRecLookup.Fields(0) ' first field in result set
sWaarde = objRecLookup.Fields(1) ' second field in result set
if not IsNull(sCode) and not IsNull(sWaarde) then
Result = Result & HtmlFormOption( sCode, sWaarde , psCurrentDft )
end if
objRecLookup.MoveNext
wend
objRecLookup.Close
Result = Result & "</select>" & vbCrlf
And than Response.Write(Result)

Here's a simple solution:
<%
Dim objCommand, objRS
Set objCommand = Server.CreateObject("ADODB.Command")
with objCommand
.ActiveConnection = objConn
.CommandType = adCmdText
.CommandText = "SELECT * FROM PASSWORDS WHERE REQ_ID= '" & req_id & "'"
Set objRS = .Execute
end with
%><select name="selectbox"><%
While NOT objRS.EOF
%><option value="<%=objRS("COLUMN_NAME")%>"><%=objRS("COLUMN_NAME")%></option><%
objRS.MoveNext
Wend
%></select><%
objRS.Close
Set objRS = Nothing
Set objCommand = Nothing
%>

Related

trying to display other fields from specific access database recordset in asp

I'm new to ASP and have a form that lets users choose a division code from a dropdown box that is populated from an access database. Once they have selected the division, I'd like to be able to collect other fields (name, address, city, state, zip) from that same recordset and pass those fields to another asp page. I'm able to write the selected code to the database, but can't figure out how to collect the other fields from that specific line in the table. My code is
<%
Set objconn = Server.CreateObject("ADODB.Connection")
objconn.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("data/jobdata.mdb")
objconn.Open
Set objRs = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM EagleLocations "
objRs.Open strSQL, objconn
Response.Write "<select name=DCode><option value='' selected></option>"
Do While Not objRS.EOF
Response.Write "<option value='" & objrs("DCode") &"'>"& objRs("DCity") &"</option>"
objRS.MoveNext
Loop
Response.Write "</select>"
objRs.Close
objconn.Close
%>
How do I get the page to also get the DName, DAddress1, DAddress2, DCity, DState, and DZIP fields from the selected DCode?
This is my receiving page code where I'm trying to get the data I collected from the form on the previous page to write to a different database:
<%
Dim objconn,strSQL,objRS
Set objconn = Server.CreateObject("ADODB.Connection")
objconn.open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("data/jobdata.mdb")
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL= "SELECT * FROM EagleLocations where Dcode =" & Request.Form("DCode")
objRs.Open strSQL, objconn
DIM strjobstart, strpm, strdcode, strdname, strcustname, strjobsite, strjobsubject, strworkmancompcode
strjobstart = Request.Form("jobstart")
strpmcode = Request.Form("pmcode")
strdcode = Request.Form("dcode")
strdname = Request.Form("dname")
strcustname = Request.Form("listcustname")
strjobsite = Request.Form("listjobsite")
strjobsubject = Request.Form("jobsubject")
strworkmancompcode = Request.Form("workmancompcode")
IF strjobstart <> "" AND strpmcode <> "" AND strdcode <> "" AND strcustname <> "" AND strjobsite <> "" AND strjobsubject <> "" AND strworkmancompcode <> "" THEN
' Process the form as you like here
' For example enter form to your database or send it via email
jobstart = request.form("jobstart")
pmcode = request.form("pmcode")
dcode = request.form("dcode")
dname = request.form("dname")
custname = request.form("listcustname")
jobsite = request.form("listjobsite")
jobsubject = request.form("jobsubject")
workmancompcode = request.form("workmancompcode")
Set Cnn = Server.CreateObject("ADODB.Connection")
Cnn.open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("data/jobcode.mdb")
strSql = "INSERT INTO JobCodeTemp (jobstart,pmcode,dcode,dname,custname,jobsite,jobsubject,workmancompcode) values( '" & jobstart & "' , '" & pmcode & "' , '" & dcode & "' , '" & dname & "' , '" & custname & "' , '" & jobsite & "' , '" & jobsubject & "' , '" & workmancompcode & "' )"
Cnn.Execute(strSql)
Cnn.Close
Set Cnn = Nothing
'Redirect to the index.asp page
Response.Redirect "display.asp"
csarafin

Can't UPDATE a large image size that was INSERTed in the database in asp.net

Here is the problem, when I insert an image (let's call it Data A) which is 1.32MB, it will be inserted successfully. But if I will insert again Data A(but it will update now because i used UPSERT, see my code), it will not be updated and it will result to connection time out.
But when i insert another data (Data B) which is only 4KB, it will also be inserted successfully and if I will insert again into it(which is update), it will be updated successfully. What can I do? I cannot understand the problem. I already made my command timeout for 2 mins but nothing happened and it just loaded forever. I also used sql transaction but it did nothing.
Here is my code:
Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Dim strConnString As String = DataSource.ConnectionString
Using con As New SqlConnection(strConnString)
Dim SQLStr As String
Dim base64String = TextArea1.Value
Dim imageBytes As Byte() = Convert.FromBase64String(base64String)
Dim FileSizeOfIMG As String
FileSizeOfIMG = imageBytes.Length
Dim ImageTypeDataOfImage As New SqlParameter("#Data", SqlDbType.Image)
ImageTypeDataOfImage.Value = imageBytes
SQLStr = "SELECT 1 FROM [Patient_Data].[dbo].[tbPatientImage] where HospNum='" & Session.Item("HospNum") & "'" & _
" and IDNum='" & Session.Item("IDNum") & "' and FileType= '" & lblHeader.Text & "'"
Dim cmd As New SqlCommand(SQLStr, con)
cmd.Connection = con
con.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
If reader.Read() Then
SQLStr = "UPDATE [Patient_Data].[dbo].[tbPatientImage] SET PatImage= #Data, FileSize= '" & FileSizeOfIMG.ToString & "' , TransDate = GetDate() where HospNum='" & Session.Item("HospNum") & "' and IDNum='" & Session.Item("IDNum") & "' and FileType= '" & lblHeader.Text & "'"
Else
SQLStr = "INSERT INTO [Patient_Data].[dbo].[tbPatientImage](HospNum,IDNum, DoctorID, PatImage , FileType, FileName, FileSize , TransDATE) " & _
" VALUES (#HospNum,#IDNum, #DoctorID, #Data, #FileType, 'Patient Photo' , #FileSize, GETDATE())"
End If
reader.Close()
cmd.CommandText = SQLStr
cmd.Parameters.AddWithValue("#HospNum", Session.Item("HospNum"))
cmd.Parameters.AddWithValue("#IDNum", Session.Item("IDNum"))
cmd.Parameters.AddWithValue("#DoctorID", Session.Item("DoctorID"))
cmd.Parameters.AddWithValue("#FileType", lblHeader.Text)
cmd.Parameters.AddWithValue("#FileSize", FileSizeOfIMG.ToString)
cmd.Parameters.Add(ImageTypeDataOfImage)
cmd.ExecuteNonQuery()
con.Close()
GetData()
End Using
End Sub
I haven't figured out what causes this but i have figured out a remedy by having a delete query first then insert data.
SQLStr = "delete FROM [Patient_Data].[dbo].[tbPatientImage] where HospNum='" & Session.Item("HospNum") & "'" & _
" and IDNum='" & Session.Item("IDNum") & "' and FileType= '" & lblHeader.Text & "'"
Dim cmd As New SqlCommand(SQLStr, con)
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
SQLStr = " INSERT INTO [Patient_Data].[dbo].[tbPatientImage](HospNum,IDNum, DoctorID, PatImage , FileType, FileName, FileSize , TransDATE) " & _
" VALUES (#HospNum,#IDNum, #DoctorID, #Data, #FileType, 'Patient Photo' , #FileSize, GETDATE())"
cmd.CommandText = SQLStr
'cmd.CommandTimeout = 120
cmd.Parameters.AddWithValue("#HospNum", Session.Item("HospNum"))
cmd.Parameters.AddWithValue("#IDNum", Session.Item("IDNum"))
cmd.Parameters.AddWithValue("#DoctorID", Session.Item("DoctorID"))
cmd.Parameters.AddWithValue("#FileType", lblHeader.Text)
cmd.Parameters.AddWithValue("#FileSize", FileSizeOfIMG)
cmd.Parameters.Add(ImageTypeDataOfImage)
cmd.ExecuteNonQuery()
con.Close()
GetData()
lblMessage.Text = "Saved."
End Using
End Sub

Customized ToolTip on MSChart Data

I'm trying to show a 'customized' ToolTip on an MSChart on an asp.net page, using vb.net
The chart displays OK, but I'm trying to get it to show the 'YEAR' as part of the tooltip, as well as the XY values.
I can't figure out how to do it.
Here's the code that I'm using to build the chart:
dt = New DataTable
dt.Columns.Add("Topic")
dt.Columns.Add("Value")
dt.Columns.Add("Year")
For i = 0 To t_YEARS.Count - 1
Sql = "SELECT att_Topic, att_Value, att_Year from Att "
Sql += " WHERE att_Year = '" & t_YEARS(i) & "' "
conn.ConnectionString = strConnString
conn.Open()
cmd = New SqlCommand(Sql, conn)
dr = cmd.ExecuteReader
While dr.Read
dt.Rows.Add(dr(0), dr(1), dr(2))
End While
dr.Close()
cmd.Dispose()
conn.Close()
Next
Chart1.DataSource = dt
Chart1.Series("Series1").XValueMember = "Topic"
Chart1.Series("Series1").YValueMembers = "Value"
Chart1.Series("Series1").ToolTip = "#VALX - #VALY"
Chart1.ChartAreas("ChartArea1").Area3DStyle.Enable3D = True
Chart1.DataBind()
Well, there may be a better answer, but I figured out a work-around anyhow ... I'm adding the YEAR to the axislabel. Then, in chart1_customize, changing the color of the bar, based on different axislabel. Seems to work.
dt = New DataTable
dt.Columns.Add("Topic")
dt.Columns.Add("Value")
dt.Columns.Add("Year")
For i = 0 To t_YEARS.Count - 1
showDATA = False
Sql = "SELECT att_Topic, att_Value, att_Year, att_Data from BWS_Att "
If (RBL_LIMIT.SelectedValue = 1) Then
showDATA = True
Sql += " WHERE att_Attrib = 'Location' "
Sql += " AND att_Data IN ('" & String.Join("','", t_LOCS) & "')"
ElseIf (RBL_LIMIT.SelectedValue = 2) Then
showDATA = True
Sql += " WHERE att_Attrib = 'Department' "
Sql += " AND att_Data IN ('" & String.Join("','", t_DEPTS) & "')"
Else
Sql += " WHERE att_Attrib = 'Company' "
End If
Sql += " AND att_Year = '" & t_YEARS(i) & "' "
Sql += " AND att_Topic IN ('" & String.Join("','", t_CATS) & "')"
Sql += " Order By att_ind"
conn.ConnectionString = strConnString
conn.Open()
cmd = New SqlCommand(Sql, conn)
dr = cmd.ExecuteReader
While dr.Read
'dt.Rows.Add(dr(0), dr(1), dr(2))
thisYR = dr(2).ToString
If (lastYR <> thisYR) Then
Chart1.Series("Series1").Points.Add(vbEmpty)
Chart1.Series("Series1").Points.Add(vbEmpty)
lastYR = thisYR
End If
If (showDATA = True) Then
Chart1.Series("Series1").Points.AddXY(dr(2).ToString & "|" & dr(3).ToString & ":" & dr(0).ToString, dr(1))
Else
Chart1.Series("Series1").Points.AddXY(dr(2).ToString & ":" & dr(0).ToString, dr(1))
End If
Chart1.Series("Series1").ToolTip = " #AXISLABEL | #VALY"
End While
dr.Close()
cmd.Dispose()
conn.Close()
Next
~~~~~~~~~~
Private Sub Chart1_Customize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Chart1.Customize
Dim C() As Drawing.Color = { _
Drawing.Color.Khaki, _
Drawing.Color.DarkSalmon, _
Drawing.Color.Goldenrod, _
Drawing.Color.MediumAquamarine, _
Drawing.Color.Tan _
}
Dim CN As Int16 = 0
Dim thisC As Int16 = 0
Dim LAST As String = String.Empty
For Each dp As System.Web.UI.DataVisualization.Charting.DataPoint In Chart1.Series("Series1").Points
Dim x As Array = dp.AxisLabel.Split(":")
If (x(0) <> "") Then
Dim H As String = x(0)
If (LAST <> H) Then
CN += 1
LAST = H
thisC = (CN Mod 5)
End If
dp.Color = C(thisC)
End If
Next
End Sub

Line 0 Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done

I have inherited some code old asp/vb code and its throwing an error which I can't find a fix for.
The server is Windows Server 2008, its running IIS7 and the SQL server is 2008.
This is the code:
<% # Language=VBScript %>
<!-- #include file="dsn.asp" -->
<!-- #include file="adovbs.inc" -->
<!-- #include file="libfunct.asp" -->
<%
'****************************************
' VARIABLES DECLARATION
'****************************************
Dim sSql, RsInsCoInfo, PolicyID, InsCo, InsOffice
Dim qsPolicyType, qsAttach, qsCLNT_ID, qsClientID
Dim CostArray(10)
Dim DescriptionArray(10)
'****************************************
' END VARIABLES DECLARATION
'****************************************
'********************************************
' RETRIEVING THE QUERYSTRINGS
'********************************************
qsAttach = Request.QueryString("Attach")
qsCLNT_ID = Request.QueryString("CLNT_ID")
qsClientID = Request.QueryString("ClientID")
qsPolicyType = Request.QueryString("PolicyType")
qsReQuote = Request.QueryString("ReQuote")
qsPolicyID = Request.QueryString("PolicyID")
'********************************************
' END RETRIEVING THE QUERYSTRINGS
'********************************************
'**********************************************
' RETRIEVING THE INSURANCE COMPANY DETAILS
'**********************************************
'Get the insurance company details
Set RsInsCoInfo = Server.CreateObject("ADODB.RecordSet")
sSQL = "SELECT InsuranceCo.*,FormPolicy.* FROM insuranceCo,FormPolicy"
sSQL = sSQL & " WHERE FormPolicy.INS_EF <= CONVERT(smalldatetime,'" & dbSaveDate(Date) & "',101)"
sSQL = sSQL & " And FormPolicy.INS_ET >= convert(smalldatetime,'" & dbSaveDate(Date) & "',101)"
sSQL = sSQL & " AND FormPolicy.PolicyType ='" & qsPolicyType & "'"
sSQL = sSQL & " AND InsuranceCo.INS_ID = FormPolicy.INS_ID"
'response.write ssql
'response.end
RsInsCoInfo.Open sSQL, OLEDBConnStr, adOpenStatic, adLockReadOnly, adCmdText
If Not RsInsCoInfo.EOF then
InsOffice = RsInsCoInfo("INS_Office")
InsCo = RsInsCoInfo("INS_DS")
Else
Response.write "<b>No underwriter available. Please contact the system administrator.<br>"
Response.write sSQL
Response.end
End if
'Close and free
RsInsCoInfo.close
Set RsInsCoInfo = Nothing
'**********************************************
' END RETRIEVING THE INSURANCE COMPANY DETAILS
'**********************************************
'*********************************************************************************
' CLIENT SEQUENCE NUMBER INCREMENT FOR THIS POLICY TYPE
'*********************************************************************************
If Not qsReQuote Then
newPolicyNumber = qsClientID & qsPolicyType
Set RsSequence = Server.CreateObject("ADODB.RecordSet")
sSQL = "SELECT * FROM Policy WHERE PolicyNumber like '%" & newPolicyNumber & "%' AND Clnt_ID=" & qsCLNT_ID
RsSequence.Open sSQL, OLEDBConnStr, adOpenStatic, adLockReadOnly, adCmdText
If RsSequence.recordcount > 0 then
PolicyID = 00
While not RsSequence.eof
If right(RsSequence("PolicyNumber"), 2) > PolicyID then
PolicyID = Cstr(right(RsSequence("PolicyNumber"), 2))
response.write PolicyID & "<br>"
End if
RsSequence.moveNext
Wend
PolicyID = PolicyID + 1
If PolicyID < 10 then
PolicyID = "0" & CStr(PolicyID)
End If
Else
PolicyID = "01"
End If
RsSequence.close
SET RsSequence = NOTHING
End If
'*********************************************************************************
' END CLIENT SEQUENCE NUMBER INCREMENT FOR THIS POLICY TYPE
'*********************************************************************************
'*********************************************************************************
' UPDATING ADDITIONNAL FIELD TO THE QUOTE CREATION
'*********************************************************************************
'Setting var
Dim strConnection, SQL_Upsate, newPolicyNumber
newPolicyNumber = qsClientID & qsPolicyType & PolicyID
If Not qsReQuote Then
'Insert Sql Statement
SQL_Update = "UPDATE Policy SET CLNT_ID=" & qsCLNT_ID & ","
SQL_Update = SQL_Update & " InsuranceCo='"& InsCo & "',"
SQL_Update = SQL_Update & " Office='"& InsOffice & "',"
SQL_Update = SQL_Update & " StatusID="& 0 & ","
SQL_Update = SQL_Update & " PolicyNumber='" & newPolicyNumber & "'"
SQL_Update = SQL_Update & " WHERE PolicyID=" & qsAttach
Else
'Insert Sql Statement
SQL_Update = "UPDATE Policy SET CLNT_ID=" & qsCLNT_ID & ","
SQL_Update = SQL_Update & " InsuranceCo='"& InsCo & "',"
SQL_Update = SQL_Update & " Office='"& InsOffice & "',"
SQL_Update = SQL_Update & " StatusID="& 0
SQL_Update = SQL_Update & " WHERE PolicyID=" & qsPolicyID
End If
'Connection object and open the db
Set strConnection = Server.CreateObject("ADODB.Connection")
strConnection.Open OLEDBConnStr
' Executing the sql insert
strConnection.Execute SQL_Update
'Now Close the connection and free up
strConnection.Close
Set strConnection = Nothing
'*********************************************************************************
' END ADDING ADDITIONAL FIELDS TO THE QUOTE CREATION
'*********************************************************************************
'*********************************************************************************
' DO CALCULATION
' - obtains file named Policy & 'Calculations.inc' = HHCalculations.inc etc.
'
' Modified by Stuart 20/5/03
'*********************************************************************************
set Rs = Server.CreateObject("ADODB.Recordset")
If Not qsReQuote Then
sSQL = "SELECT Policy.* FROM Policy WHERE Policy.PolicyID=" & qsAttach
Else
sSQL = "SELECT Policy.* FROM Policy WHERE Policy.PolicyID=" & qsPolicyID
End If
Rs.Open sSQL, OLEDBConnStr, adOpenkeyset, adLockPessimistic, adCmdText
'********************************************
'Response.write "<B>Policy table For Testing Only<P></b>"
'For Each fld in Rs.fields
' Response.write fld.name & " = " & fld.value & "<br>"
'Next
'Response.end
'**********************************************
Agent = 0
Agent2 = 0
AgentIntro = 0
'Open rsAccount for writing account entries to the PolicyAmount table
'** Comment derek to Stuart -> wont we be better here to find the agent with the code?
If Session("Agent") <> "" then
set RsAgent = Server.CreateObject("ADODB.Recordset")
sSQL = "Select * from Agents Where Name = '" & Session("Agent") & "'"
RsAgent.Open sSQL, OLEDBConnStr, adOpenkeyset, adLockPessimistic, adCmdText
Agent = rsAgent("commission")
End if
'If a park was involved for a new business then the introductory rate is required.
If Session("Village_Name") <> "" then
set RsPark = Server.CreateObject("ADODB.Recordset")
If IsNumeric(Session("Village_Name")) Then
sSQL = "Select * from Park Where ParkID = '" & Session("Village_Name") & "'"
Else
sSQL = "Select * from Park Where ParkID = '" & Session("reParkID") & "'"
End If
RsPark.Open sSQL, OLEDBConnStr, adOpenkeyset, adLockPessimistic, adCmdText
If RsPark.eof then
Response.write "<b>" & ssql & "<P>No Park record found - Line 189 QuoteSave2.asp<P>Please contact you system administrator."
'Response.end
Else
AgentIntro = RsPark("Introduction")
End if
End if
set RsAccount = Server.CreateObject("ADODB.Recordset")
set RsQuestions = Server.CreateObject("ADODB.Recordset")
If Not qsReQuote Then
sSQL = "SELECT * FROM PolicyAmount WHERE PolicyID=" & qsAttach
Else
sSQL = "SELECT * FROM PolicyAmount WHERE PolicyID=" & qsPolicyID
End If
RsAccount.Open sSQL, OLEDBConnStr, adOpenkeyset, adLockPessimistic, adCmdText
If Not qsReQuote Then
sSQL = "SELECT * FROM PolicyQuestions WHERE PolicyID=" & qsAttach
Else
sSQL = "SELECT * FROM PolicyQuestions WHERE PolicyID=" & qsPolicyID
End If
RsQuestions.Open sSQL, OLEDBConnStr, adOpenkeyset, adLockPessimistic, adCmdText
If Not qsRequote Then
RsAccount.Addnew
End If
If Not qsRequote Then
RsAccount("PolicyID") = qsAttach
linkID = qsAttach
Else
RsAccount("PolicyID") = qsPolicyID
linkID = qsPolicyID
End If
sTargetFile = qsPolicyType & "Calculations.inc"
sTargetFileContents = GetFileContentsForExecution(sTargetFile)
Execute sTargetFileContents
'*********************************************************************************
' END DO CALCULATION
'*********************************************************************************
'*********************************************************************************
' WRITE COSTS TO THE TABLE
'*********************************************************************************
'Update data to the PolicyAmount table
RsAccount("PolicyAmount_IB") = Session("Login")
RsAccount("PolicyAmount_IT") = Date
RsAccount.Update
'**********************************************
'Response.write "<P><B>PolicyAmount table For Testing Only<P></b>"
'For Each fld in RsAccount.fields
' Response.write fld.name & " = " & fld.value & "<br>"
'Next
'Response.write "<P><B><a href='default.asp'>Home</a>"
'Response.end
'***********************************************
'Clean up
RsAccount.Close
Set RsAccount = Nothing
Rs.update
Rs.Close
Set Rs = Nothing
RsQuestions.Close
Set RsQuestions = Nothing
'RsPark.close
'Set RsPark = Nothing
'Finish with this second saving so redirect to the policy page
If Not qsReQuote Then
Response.redirect "Policy.asp?PolicyID=" & qsAttach & "&CLNT_ID=" & qsCLNT_ID & "&ClientID=" & qsClientID & "&PolicyType=" & qsPolicyType
Else
Response.redirect "Policy.asp?PolicyID=" & qsPolicyID & "&CLNT_ID=" & qsCLNT_ID & "&ClientID=" & qsClientID & "&PolicyType=" & qsPolicyType
End If
%>
This is the error: "Warning: File /quotesave2.asp Line 0 Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.. ."
It really doesn't give me much to go on and any help/insight would be greatly appreciated.
Thanks.
It's real tough to pin down the exact issue with no line number. I noticed towards the end of the script, you are adding a new record to RsAccount and assigning values to the recordset fields. In the past, I have gotten the "Multiple-step OLE DB operation generated errors" error due to type mismatches between the VBScript variable and the recordset field type. Double-check the data type of the columns that you are updating, and if necessary, explicitly convert values before assigning them to the recordset (for example, using CLng for numbers).
This is classic, i handle these problems by logging each command to the db just before executing. So eg
log(sSql)
RsAccount.Open sSQL, OLEDBConnStr, adOpenkeyset, adLockPessimistic, adCmdText
Where log(tekst) is a sub which writes to a txt file the passed text. Now when you encounter an error execution stops and you check your log. The last entry is the sql generating the error. Execute this sql in an interactive environment where you can easily adjust the text and try again and where you get more accurate error from your dbclient. Don't know what it is for Sql Server, i use Oracle and there it is Sql*Plus, i'm sure there must be others for Sql Server. Once you corrected your sql, paste it in your code, replacing your literals with variables. Request your page again and do the above until all your sql is correct.
First, your SELECT statement is selecting multiple field with same name which might cause a problem. Change your statement to this: (You might need to change the table of INS_DS, I just guessed)
sSQL = "SELECT ic.INS_Office, fp.INS_DS "&_
"FROM insuranceCo ic INNER JOIN FormPolicy fp ON ic.INS_ID = fp.INS_ID "&_
"WHERE fp.INS_EF <= CONVERT(smalldatetime,'" & dbSaveDate(Date) & "',101) "&_
"AND fp.INS_ET >= convert(smalldatetime,'" & dbSaveDate(Date) & "',101) "&_
"AND fp.PolicyType = '" & qsPolicyType & "'"
If still same error, I remember getting this one when messing around with Date/Time fields so those two date fields are suspects. For sake of debug try to select without that filter and see what happens:
sSQL = "SELECT ic.INS_Office, fp.INS_DS "&_
"FROM insuranceCo ic INNER JOIN FormPolicy fp ON ic.INS_ID = fp.INS_ID "&_
"WHERE fp.PolicyType = '" & qsPolicyType & "'"

ASP Classic searching multiple

Question: anyone have multiple searching coding using asp ? Can you share?
This is what I want to do..
There are 3 option or searching..by name, by location, by region
For the first display all data with paging..on top it has searching.
<textfield>name</textfield><list/menu>location</list/menu><list/menu>region</list/menu>
when search by region it will display all region are selected.
Then it allow to filter by name to get specific
<%
Dim adoCon
Dim rsGuestbook
Dim strSQL
Dim lngRecordNo
lngRecordNo = CLng(Request.QueryString("ID"))
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database'
strSQL = "SELECT * FROM tbl_Master WHERE ID=" & lngRecordNo
rsGuestbook.Open strSQL, oConn
%>
Here is a querystring search be name,department,age. It works properly. It might help you. Just fetch your values. Put those in proper places. And don't forget to change your tablename
name1=request.QueryString("name")
dept1=request.QueryString("dept")
age1=request.QueryString("age")
sqlStr="Select * from Student_Entry"
sqlWhere=""
if name1<>"" then
sqlWhere = " Where S_name='"&name1&"'"
end if
if dept1<>"" then
if sqlWhere = "" then
sqlWhere = " Where S_dept='"&dept1&"'"
else
sqlWhere = sqlWhere&" And S_dept='"&dept1&"'"
end if
end if
if age1<>"" then
if sqlWhere = "" then
'sqlWhere = " Where S_age="&age1&""
sqlWhere = " Where S_age"&agestr&age1
else
'sqlWhere = sqlWhere&" And S_age="&age1&""
sqlWhere =sqlWhere&" And S_age"&agestr&age1
end if
end if
sqlStr = sqlStr & sqlWhere
it sounds like you are describing multiple dependent lists (?)
there is an example here with demo:
http://www.aspkey.net/aspkey/_articles/asp/showarticle.asp?id=100
strname , strlocation and strregion value will depend on selection if not select then default value will be "".
strSQL = "SELECT * FROM tbl_Master WHERE ID=" & lngRecordNo
if strname <> "" THEN
strSQL = strSQL & " and name ='"& strname &"' "
END IF
if strlocation <> "" THEN
strSQL = strSQL & " and location='"& strlocation &"'
END IF
if strregion <> "" THEN
strSQL = strSQL & " and region='"& strregion &"'
END IF
rsGuestbook.Open strSQL, oConn

Resources