Click to See Complete Forum and Search --> : debugging needed(urgent)
venkitaraman
August 27th, 2003, 06:16 AM
hai guys this is a asp code and help me to debug it
<html>
<body>
<%response.contenttype = "text/html" %>
<%request.querystring ('searchstring') %>
<%
Dim sResult
Sub Label1_Click()
'Execute Query
Set conn = CreateObject("ADODB.Connection")
OnErrorExit "Error creating object: ADODB.Connection"
Set cmd = CreateObject("ADODB.Command")
OnErrorExit "Error creating object: ADODB.Command"
Set rs = CreateObject("ADODB.RecordSet")
OnErrorExit "Error creating object: ADODB.Recordset"
conn.ConnectionString = "provider=msdaipp.dso"
conn.CommandTimeout = 0
conn.Open "http://kneserver4.wipro.com/kmtest/documents/Traniee", "tr7253","venkisgeethu"
OnErrorExit "Error opening connection"
Set cmd.ActiveConnection = conn
cmd.CommandText = "select ""DAV:displayname"" from scope('deep traversal of ""/kmtest/documents/Traniee""') where freetext('workspace')"
OnErrorExit "Error setting command properties"
rs.Open cmd
OnErrorExit "Error executing query"
dumprowset rs
End Sub
Sub dumprowset(rs)
Label1.Visible = False
Dim i, j
Dim s
While Not rs.EOF
' sResult(i) = ""
'sHead = i & ") "
For j = rs.Fields.Count - 2 To rs.Fields.Count - 1
sResult = rs(j).Value & vbclrf
List1.AddItem sResult
Next
rs.MoveNext
Wend
'MsgBox i & " Results."
End Sub
%>
dim array(),i
strHTML = strHTML & "<SELECT>"
for i=1 to aray.length
strHTML = strHTML & "<OPTION value=""" & array(i) & """>""" & array(i) & """</OPTION>"
next i
strHTML = strHTML & "</SELECT>"
response.write strHTML
%>
</body>
</html>
Satishpp
August 27th, 2003, 12:38 PM
So what is this code supposed to do?
and what is it doing?
Can you give us a clue about the problem you are facing?
Satish
venkitaraman
August 27th, 2003, 11:00 PM
The code is supposed to make a search in the local server and list me all the documents;
i also have a html file where i 'call' this asp file using get method;
the problem is that iam not getting any output;when i make the html file run (it has 'onclick 'input) then i get a 'open with'
dialog box and this itself is a error; and i cant open the file as internet explorer;
i dont know whats the problem; i also have iis server running in my machine
can u ppls try to run the code and see whats happening?
thanks and regds
venki
ZoSoo7
August 27th, 2003, 11:04 PM
Ya, if we can help, we will definately need some more explanation. 1 thing I see from glancing at this, is that you are trying to handle you're events with server side code, that can't be done, and if you are going to do db work with events, you have to set up your app so you can do it with RMS.
venkitaraman
August 27th, 2003, 11:12 PM
actually when i run the code in vb environment (as vb codes only)
iam able to get the output.then why cant i get output using asp.
iam sure the logic is exactly the same!
Satishpp
August 28th, 2003, 01:06 PM
I could not make much sense of that code. Anyhow, a few points
1) use server.createobject(...)
2) You have mentioned that there is no output. Well, there is no code written to give any output.
In the while and for loops in which you are traversing the recordset, there is no response.write or any other code that will produce output.
Also, what is List1 in the statement "List1.AddItem sResult". That does not seem to be valid ASP
Hope this helps
Satish
ZoSoo7
August 28th, 2003, 02:06 PM
Well, there is a huge difference in the way that VB apps work compared to asp. I'll try to explain this briefly and the best I can.
All of your code with in the <% %> delimeters run on the server, meaning all of that code is processed on your server and then sends it down to the client as HTML, and there is no connection after that. When you have a VB application, that program is running as a client, so you have access to all the events, like when you click on lables, and you can still do db work. So you are not going to be able to do any server side processing (retrieving file names) from events in a web page, the page must be submitted to the server. Once you understand how this works, you will be able to do anything with ASP. Let me make a recomendation. This is what I would try, create a web page and have a form that posts to another asp page, do you're proecessing and response.write the document names, don't even try to mess with the event handlers
html page
<form id=myform action="aspPage.asp" method=post>
<input type=text name=searchString>
<input type=submit value=Submit>
<form>
now your asp page (aspPage.asp)
<%
dim oRs, oConn
set oRs = CreateObject("ADODB.Recordset")
set oConn = CreateObject("ADODB.Connection")
'do your connection string
set oRs = oConn.execute("select blah from blah where " & _
"blah = '"& request.form("searchString") &"' ")
do while not oRs.eof and not oRs.bof
response.write oRs("blah")
oRs.movenext()
loop
%>
Hope this helps
venkitaraman
September 2nd, 2003, 01:44 AM
i have converted the asp codes in the following way:-
<html>
<body>
<%
dim Rs , Conn
Set Conn = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
Set Rs = CreateObject("ADODB.RecordSet")
Conn.ConnectionString = "provider=msdaipp.dso"
Conn.CommandTimeout = 0
Conn.Open "http://kneserver4.wipro.com/kmtest/documents/Traniee", "tr7251","venkisgeethu"
OnErrorExit "Error opening connection"
Set Rs=conn.execute("select ""DAV:displayname"" from scope('deep traversal of ""/kmtest/documents/Traniee""') where & "free text (searchstring)='"& request.form("searchstring")&'"")
Rs.Open cmd
do while not Rs.eof and not Rs.bof
response.write Rs("str html")
Rs.movenext()
loop
%>
but the following error is comming .i tried to debug it but iam not able to.pls help
Microsoft VBScript compilation error '800a03ee'
Expected ')'
/asp/5.asp, line 12
Set Rs=conn.execute("select ""DAV:displayname"" from scope('deep traversal of ""/kmtest/documents/Traniee""') where & "free text (searchstring)='"& request.form("searchstring")&'"")
-----------------------------------------------------------------------------------------------------------------------^
thanks and regds
venki
ZoSoo7
September 3rd, 2003, 07:35 PM
It's the way you are concatenating your query. The easiest way to fix these is to run the query in whatever db tool you have, i.e. query analyzer for sql server. Then once the query runs, paste it into your code between the (" "). After that, whatever values you plugged in your query, replace it with the asp values and add the " & " for concatenation. Good luck.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.