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
Related
I was reported from an user regarding a web page which I made on an ASP.NET Web site.
And still am not sure whether it's true or not.
Although the Web page was created to download data from an Oracle Database,
it seems not to download data entiley sometime, according to her.
The code which is related to what I mentioned is below,
Private Function makeCSVData() As String
Dim sb As New StringBuilder
sb.AppendLine("検索値, 検索値名称, 親品目コード, 親品名, 親単位, 子品目コード, 子品名, 子単位")
Dim strSQL As String
If RadioButtonList2.SelectedValue = 0 Then
strSQL = "SELECT Q.*, M0.品名 検索値名称 FROM (SELECT CONNECT_BY_ROOT Z.親品目コード 検索値, Z.親品目コード, M1.品名 親品名, M1.単位コード 親単位, Z.子品目コード, M2.品名 子品名, M2.単位コード 子単位 "
strSQL = strSQL & "FROM (SELECT * FROM M_BOM WHERE 使用開始日<=SYSDATE AND 使用停止日>SYSDATE) Z "
strSQL = strSQL & "LEFT OUTER JOIN M_HINMO M1 ON M1.品目コード=Z.親品目コード "
strSQL = strSQL & "LEFT OUTER JOIN M_HINMO M2 ON M2.品目コード=Z.子品目コード "
strSQL = strSQL & "START WITH Z.親品目コード IN (SELECT H.FIELD_S1 FROM SMD_GEN.T_PARAMH H WHERE H.HOSTID='" & CL_Hsn & "') "
strSQL = strSQL & "CONNECT BY PRIOR Z.子品目コード = Z.親品目コード ORDER BY 検索値, 親品目コード, 子品目コード) Q LEFT OUTER JOIN M_HINMO M0 ON M0.品目コード=Q.検索値"
Else
strSQL = "SELECT Q.*, M0.品名 検索値名称 FROM (SELECT CONNECT_BY_ROOT Z.子品目コード 検索値, Z.親品目コード, M1.品名 親品名, M1.単位コード 親単位, Z.子品目コード, M2.品名 子品名, M2.単位コード 子単位 "
strSQL = strSQL & "FROM(SELECT * FROM M_BOM WHERE 使用開始日<=SYSDATE And 使用停止日>SYSDATE) Z "
strSQL = strSQL & "LEFT OUTER JOIN M_HINMO M1 ON M1.品目コード=Z.親品目コード "
strSQL = strSQL & "LEFT OUTER JOIN M_HINMO M2 ON M2.品目コード=Z.子品目コード "
strSQL = strSQL & "START WITH Z.子品目コード IN (SELECT H.FIELD_S1 FROM SMD_GEN.T_PARAMH H WHERE H.HOSTID='" & CL_Hsn & "') "
strSQL = strSQL & "CONNECT BY PRIOR Z.親品目コード=子品目コード ORDER BY 検索値, 親品目コード, 子品目コード) Q LEFT OUTER JOIN M_HINMO M0 ON M0.品目コード=Q.検索値"
End If
System.Diagnostics.Debug.Print("###" & strSQL & "###")
Dim conn As New OracleConnection(CnStringP)
Dim cmd As New OracleCommand(strSQL, conn)
cmd.CommandType = CommandType.Text
Try ' Open the connection
conn.Open()
Dim dr As OracleDataReader = cmd.ExecuteReader()
Do While dr.Read
sb.Append("""" & replaceDoubleQuotes(dr("検索値")) & """,")
sb.Append("""" & replaceDoubleQuotes(dr("検索値名称")) & """,")
sb.Append("""" & replaceDoubleQuotes(dr("親品目コード")) & """,")
sb.Append("""" & replaceDoubleQuotes(dr("親品名")) & """,")
sb.Append("""" & replaceDoubleQuotes(dr("親単位")) & """,")
sb.Append("""" & replaceDoubleQuotes(dr("子品目コード")) & """,")
sb.Append("""" & replaceDoubleQuotes(dr("子品名")) & """,")
sb.Append("""" & replaceDoubleQuotes(dr("子単位")) & """,")
sb.Append(vbCrLf)
Loop
conn.Close()
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Return sb.ToString()
End Function
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim startupScript As String
Dim dtNow As DateTime = DateTime.Now
Dim csvString As String = makeCSVData()
Dim csvFile As String
csvFile = "BOMSERCH_" & dtNow.ToString("yyyyMMddHHmmss")
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=" & csvFile & ".csv")
Response.BinaryWrite(Encoding.GetEncoding("Shift-JIS").GetBytes(csvString))
Response.End()
End Sub
could you tell me the reason or what I should try, if you know?
Thank you.
Ok, so while Response write (BinaryWrite) does and should work?
I suggest using transmit file.
eg:
strFile = Server.MapPath(#"~/UpLoadFiles/" + strFileOnly);
string sMineType = MimeMapping.GetMimeMapping(strFileOnly);
Response.ContentType = sMineType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + strFileOnly);
Response.TransmitFile(strFile);
Response.End();
However, you posted code does have response.End, and should work, but as a general rule, TransmitFile does produce better results, and for one, it does not read the whole file into memory first - but streams it out, and thus can reduce the memory load on the server. And since it streams out better, then the data stream tends to work better.
And failures can be the result of less than ideal internet connection, but TransmitFile I find tends to produce better results.
So, try code similar to above - see if this reduces the failure rates.
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
I need to compare between dates by converting the SQL Server datetime value (ex: 20-Feb-14 12:52:48 PM) to yyyyMMddhhmmss
I tried the following but still need to replace the spaces and ":" and can't do multiple replace
REPLACE(RIGHT(CONVERT(VARCHAR(19), (OrderDate), 120), 19), '-', '')
Any ideas?
Here is my full code:
Dim dsOrders As New DataSet
Dim daOrders As SqlDataAdapter
Dim Cnn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"))
Dim strSQL As String
strSQL = "Select O.OrderID,O.Status,O.OrderDate, O.DeliveryDate, OD.Title,OD.Data from SPLBL_Orders O join SPLBL_OrderData OD on O.OrderID=OD.OrderID where OD.LanguageID=1"
'''' Generate Filter Results
If txtKeyword.Text.ToString <> "" Then
strSQL = strSQL + " OR OD.Data Like N'%" + txtKeyword.Text.ToString + "%'"
End If
If txtMemberID.Text.ToString <> "" Then
strSQL = strSQL + " and O.MemberID = " + txtMemberID.Text.ToString
End If
If chkFeatured.Checked Then
strSQL = strSQL + " and O.Featured=1"
End If
Dim lstStatus As ListItem
Dim strStatus As String = ""
For Each lstStatus In ddlStatus.Items
If lstStatus.Selected Then
If strStatus <> "" Then
strStatus = strStatus + ","
End If
strStatus += lstStatus.Value.ToString()
End If
Next
If strStatus <> "" Then
strSQL = strSQL + " and O.Status IN(" + strStatus + ")"
End If
If txtStartDate.Text <> "" Then
Dim strSdate As DateTime = txtStartDate.Text.ToString
Dim strStart = strSdate.ToString("yyyyMMddhhmmss")
If txtEndDate.Text <> "" Then
Dim strEdate As DateTime = txtEndDate.Text.ToString
Dim strEnd As String
If txtEndDate.Text <> "" Then
strEnd = strEdate.ToString("yyyyMMddhhmmss")
Else
strEnd = Date.Today.ToString("yyyyMMddhhmmss")
End If
strSQL = strSQL + " and REPLACE(REPLACE(REPLACE((CONVERT(VARCHAR(19), (OrderDate), 120)), ':', ''), '-', ''), ' ', '') Between " + strStart + " and " + strEnd + ""
End If
End If
strSQL = strSQL + " order by OD.OrderID desc"
You're causing yourself unneeded trouble because you're going about this the hard way. You should be using parameterized SQL for this (and any time you want to pass a variable value into an SQL query):
strSQL = strSQL + " and OrderDate Between #dateStart and #dateEnd"
Then pass your start date and end dates to the query as DateTime parameters with the names #dateStart and #dateEnd.
For information about using parameterized queries in VB:
How do I create a parameterized SQL query? Why Should I?
Here's essentially what you need to do. Note that I've created an SqlCommand object and added parameters to it as the query is built up. You'll need to use this SqlCommand object when you execute the actual query.
Dim dsOrders As New DataSet
Dim daOrders As SqlDataAdapter
Dim Cnn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"))
Dim Cmd As New SqlCommand()
Cmd.Connection = Cnn
Dim strSQL As String
strSQL = "Select O.OrderID,O.Status,O.OrderDate, O.DeliveryDate, OD.Title,OD.Data from SPLBL_Orders O join SPLBL_OrderData OD on O.OrderID=OD.OrderID where OD.LanguageID=1"
'''' Generate Filter Results
If txtKeyword.Text <> "" Then
strSQL += " OR OD.Data Like #keyword"
Cmd.Parameters.AddWithValue("#keyword", "%" + txtKeyword.Text + "%")
End If
If txtMemberID.Text <> "" Then
strSQL += " and O.MemberID = #memberId"
Cmd.Parameters.AddWithValue("#memberId", txtMemberID.Text)
End If
If chkFeatured.Checked Then
strSQL += " and O.Featured=1"
End If
Dim lstStatus As ListItem
Dim statusCount As Integer = 1
Dim strStatus As String = ""
For Each lstStatus In ddlStatus.Items
If lstStatus.Selected Then
Dim paramName As String = "#status" + statusCount
strStatus += ", " + paramName
Cmd.Parameters.AddWithValue(paramName, lstStatus.Value.ToString)
statusCount += 1
End If
Next
If strStatus <> "" Then
strSQL += " and O.Status IN(" + strStatus.Substring(2) + ")"
End If
If txtStartDate.Text <> "" Then
Dim startDate As DateTime = DateTime.Parse(txtStartDate.Text)
Dim endDate As DateTime
If txtEndDate.Text <> "" Then
endDate = DateTime.Parse(txtEndDate.Text)
Else
endDate = DateTime.Today
End If
strSQL += " and OrderDate Between #startDate and #endDate"
Cmd.Parameters.AddWithValue("#startDate", startDate)
Cmd.Parameters.AddWithValue("#endDate", endDate)
End If
strSQL += " order by OD.OrderID desc"
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 & "'"
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
%>