|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Stored proc with a parameter
<i><b>Originally posted by : meipoon (meipoon1@yahoo.com)</b></i><br /><%<br />'Declare variables<br />dim conn<br />dim rs<br />dim strsql<br />dim strUserName<br /><br />'Set the information submitted to a local variable<br />strUserName= request("user_name")<br /><br />'Connection and Recordset object<br /> Set conn = Server.CreateObject("ADODB.Connection")<br /> Conn.Open "driver={SQL Server};server=ops02;uid=webreader;pwd=web;databas e=msdb"<br /> Server.ScriptTimeout = "120" <br /> conn.CommandTimeout = 240 <br /> <br />'Set the string that will be passed to the database and execute the <br />'stored procedure. This will return a recordset<br />strSql = "exec SP_GET_BILLING_INFO1" & strUserName<br />response.write strSql<br />set Rs = server.createobject("adodb.recordset")<br />Rs.open strSql, conn<br />rs.movefirst<br /> <br />%><br /><br /><TABLE BORDER="1" width="80%"><br /><TR> <br /><% For Each Field In RS.Fields %><br /><TH> <br /><%<br />response.write Field.name<br />%> <br /></TH> <br /><% Next %> <br /></TR><br />'This section writes out the DATA of the fields in the Recordset<br /><% Do While Not RS.EOF %> <br /><TR> <br /><% For Each Field In RS.Fields %> <br /><TD ALIGN=center> <br /><%<br />Response.Write Field.Value <br />%> <br /></TD><br /><% Next <br />RS.MoveNext %> <br /></TR> <br /><% Loop %> <br /></TABLE> <br /></body><br /><% <br />Rs.close<br />set Rs = nothing<br />conn.close<br />set conn = nothing<br />%><br /><br /><br /><br />Above is my asp output code, specified a parameter "user_name", but it wont work, could any one tell me what may go wrong? Thanks.<br />
|
|
#2
|
|||
|
|||
|
<i><b>Originally posted by : (kots_999@hotmail.com)</b></i><br />Hi<br />Try with a 'space' after sp_name.<br />exec "sp_name " & strUserName.<br />Kots<br /><br /><br /><br />------------<br />meipoon at 5/2/2000 6:16:16 PM<br /><br /><%<br />'Declare variables<br />dim conn<br />dim rs<br />dim strsql<br />dim strUserName<br /><br />'Set the information submitted to a local variable<br />strUserName= request("user_name")<br /><br />'Connection and Recordset object<br /> Set conn = Server.CreateObject("ADODB.Connection")<br /> Conn.Open "driver={SQL Server};server=ops02;uid=webreader;pwd=web;databas e=msdb"<br /> Server.ScriptTimeout = "120" <br /> conn.CommandTimeout = 240 <br /> <br />'Set the string that will be passed to the database and execute the <br />'stored procedure. This will return a recordset<br />strSql = "exec SP_GET_BILLING_INFO1" & strUserName<br />response.write strSql<br />set Rs = server.createobject("adodb.recordset")<br />Rs.open strSql, conn<br />rs.movefirst<br /> <br />%><br /><br /><TABLE BORDER="1" width="80%"><br /><TR> <br /><% For Each Field In RS.Fields %><br /><TH> <br /><%<br />response.write Field.name<br />%> <br /></TH> <br /><% Next %> <br /></TR><br />'This section writes out the DATA of the fields in the Recordset<br /><% Do While Not RS.EOF %> <br /><TR> <br /><% For Each Field In RS.Fields %> <br /><TD ALIGN=center> <br /><%<br />Response.Write Field.Value <br />%> <br /></TD><br /><% Next <br />RS.MoveNext %> <br /></TR> <br /><% Loop %> <br /></TABLE> <br /></body><br /><% <br />Rs.close<br />set Rs = nothing<br />conn.close<br />set conn = nothing<br />%><br /><br /><br /><br />Above is my asp output code, specified a parameter "user_name", but it wont work, could any one tell me what may go wrong? Thanks.<br />
|
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Stored proc with a parameter |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|