Hello,
I have a stored procedure (SQL Server 2005) which is the following:
The aim of this is to be passed 2 parameters, database name (selecting by the user on-screen) and telephone; these parameters are used to pull the correct customers info from the dB.
Here is the presentation / data-access i.e. *.asp page:
When printing the variable SQLQuery to screen then running through SQL Server Management Studio, there is data returned, however, here there is none. I am using the right database name, connection string etc i.e. I am getting no error, just a BOF, which I know is not the case for the data I am querying.
Is it apparent what the problem is in the above? I am pretty sure it's not the sproc as when run through SSMS it returns data.
Thanks in advance I hope!
J
I have a stored procedure (SQL Server 2005) which is the following:
Code:
CREATE PROCEDURE [dbo].[ReturnCustDetailsFromTelNumber]
@DatabaseName varchar(200),
@Telephone varchar(20)
AS
BEGIN
DECLARE @UseStatement varchar(2000)
SET @UseStatement = ('USE [' + @DatabaseName + ']')
EXEC (@UseStatement + ' SELECT * from CustomerData where Telephone = ''' + @Telephone + '''')
END
Here is the presentation / data-access i.e. *.asp page:
Code:
<%
Err.clear
On Error Resume Next
SQLQuery = ""
Set db21 = Server.CreateObject( "ADODB.Connection" )
OdbcConStr = Session("DBConnection") & ""
db21.Open OdbcConStr
SQLQuery = "EXEC dbo.ReturnCustDetailsFromTelNumber" & " '" & Session("CustomerDatabase") & "', '" & Session("custTelephone") & "'"
Session( "LastRunQuery" ) = SQLQuery
Set ReturnedCustomers = db21.Execute( SQLQuery )
%>
<%if Err.Number <> 0 then%>
<p>An Error Occured 1</p>
<%=Err.Description %>
<%else if ReturnedCustomers.BOF then %>
<p>No customer found!</p>
<% else %>
<table>
<tr>
<th>Forename</th>
<th>Surname</th>
<th>Address1</th>
<th>Postcode</th>
</tr>
<%Do While Not ReturnedCustomers.EOF %>
<tr>
<td><%=ReturnedCustomers("P1Firstname") %></td>
<td><%=ReturnedCustomers("P1Surname") %></td>
<td><%=ReturnedCustomers("Address1") %></td>
<td><%=ReturnedCustomers("Postcode") %></td>
</tr>
<% ReturnedCustomers.MoveNext %>
<%Loop %>
<%End If %>
<%End If%>
<%ReturnedCustomers.close%>
<%db21.close%>
</table>
Is it apparent what the problem is in the above? I am pretty sure it's not the sproc as when run through SSMS it returns data.
Thanks in advance I hope!
J
Comment