Mina procedurer är provade i Queryanalyzer och fungerar, Det första jag ser är att du lägger till parametrarna för varje loop. Flytta upp dem till innan loopen körs:Fel loopen eller??
Loopen fungerar ett varv och lägger in rätt värde och sen kommer felmeddelandet som ligger under koden.
Någon som ser något fel på koden? förutom att den är lite struligt skriven... =)
Dim Dbcon As New SqlConnection(strConn)
Dim SQLCmd_g_book_roomID As SqlCommand
SQLCmd_g_book_roomID = New SqlCommand("bfh_g_book_roomID", Dbcon)
SQLCmd_g_book_roomID.CommandType = CommandType.StoredProcedure
Dim f As Integer
For f = 0 To tvList.Count - 1 Dim booknr As SqlParameter = SQLCmd_g_book_roomID.Parameters.Add("@booknr", SqlDbType.Int)
booknr.Value = bID_parm.Value
'Måste loopa fram rummen!!
Dim roomnr As SqlParameter = SQLCmd_g_book_roomID.Parameters.Add("@roomnr", SqlDbType.Int)
roomnr.Value = tvList(f)
Dim book_roomID As Integer
Dbcon.Open()
Dim dr4 As SqlDataReader = SQLCmd_g_book_roomID.ExecuteReader()
While dr4.Read
'Lägger in tillval i droplisten
book_roomID = (dr4.Item("book_roomID"))
End While
dr4.Close()
Dbcon.Close()
'--------------------------------------------------------------------------
Dim DbCon10 As New SqlConnection(strConn)
Dim SQLCmd_a_room_extra As SqlCommand
SQLCmd_a_room_extra = New SqlCommand("bfh_a_roomextra", DbCon10)
SQLCmd_a_room_extra.CommandType = CommandType.StoredProcedure
Dim booknr_parm As SqlParameter = SQLCmd_a_room_extra.Parameters.Add("@extraID", SqlDbType.Int)
booknr_parm.Value = 22
'Måste loopa fram rummen!!
Dim roomnr_parm As SqlParameter = SQLCmd_a_room_extra.Parameters.Add("@book_roomID", SqlDbType.Int)
roomnr_parm.Value = book_roomID
DbCon10.Open()
Dim dr15 As SqlDataReader = SQLCmd_a_room_extra.ExecuteReader()
dr15.Close()
DbCon10.Close()
Next f
FELMEDELANDET:
Serverfel i tillämpningsprogrammet /bfh.
________________________________________
Procedure or function bfh_g_book_roomID has too many arguments specified.
Beskrivning: Ett undantag som inte kunde hanteras inträffade när den aktuella webbegäran kördes. Mer information om felet och var i koden det uppstod finns i stackspårningen.
Undantagsinformation: System.Data.SqlClient.SqlException: Procedure or function bfh_g_book_roomID has too many arguments specified.
Källfel:
Rad 197: Dim book_roomID As Integer
Rad 198: Dbcon.Open()
Rad 199: Dim dr4 As SqlDataReader = SQLCmd_g_book_roomID.ExecuteReader()
Rad 200: While dr4.Read
Rad 201: 'Lägger in tillval i droplisten
Källfil: c:\inetpub\wwwroot\bfh\a_book02.aspx.vb Rad: 199
Stackspårning:
[SqlException: Procedure or function bfh_g_book_roomID has too many arguments specified.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader()
bfh.a_book02.btn_book_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\bfh\a_book02.aspx.vb:199
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
REATE PROCEDURE bfh_g_book_roomID
@booknr int,
@roomnr int
AS
SELECT book_roomID from tbl_book_room
WHERE booknr=@booknr
AND roomnr=@roomnr
GOSv: Fel loopen eller??
Dim Dbcon As New SqlConnection(strConn)
Dim SQLCmd_g_book_roomID As SqlCommand
Dim booknr As SqlParameter
Dim roomnr As SqlParameter
Dim f As Integer
SQLCmd_g_book_roomID = New SqlCommand("bfh_g_book_roomID", Dbcon)
SQLCmd_g_book_roomID.CommandType = CommandType.StoredProcedure
booknr = SQLCmd_g_book_roomID.Parameters.Add("@booknr", SqlDbType.Int)
roomnr = SQLCmd_g_book_roomID.Parameters.Add("@roomnr", SqlDbType.Int)
For f = 0 To tvList.Count - 1
Dim book_roomID As Integer
booknr.Value = bID_parm.Value
roomnr.Value = tvList(f)
'Måste loopa fram rummen!!
Dbcon.Open()
Dim dr4 As SqlDataReader = SQLCmd_g_book_roomID.ExecuteReader()
While dr4.Read
'Lägger in tillval i droplisten
book_roomID = (dr4.Item("book_roomID"))
End While
dr4.Close()
Dbcon.Close()
'--------------------------------------------------------------------------
Dim DbCon10 As New SqlConnection(strConn)
Dim SQLCmd_a_room_extra As SqlCommand
SQLCmd_a_room_extra = New SqlCommand("bfh_a_roomextra", DbCon10)
SQLCmd_a_room_extra.CommandType = CommandType.StoredProcedure
Dim booknr_parm As SqlParameter = SQLCmd_a_room_extra.Parameters.Add("@extraID", SqlDbType.Int)
booknr_parm.Value = 22
'Måste loopa fram rummen!!
Dim roomnr_parm As SqlParameter = SQLCmd_a_room_extra.Parameters.Add("@book_roomID", SqlDbType.Int)
roomnr_parm.Value = book_roomID
DbCon10.Open()
Dim dr15 As SqlDataReader = SQLCmd_a_room_extra.ExecuteReader()
dr15.Close()
DbCon10.Close()
Next f
Håller med om att koden är struligt skriven. :P
Tror det skall kunna gå att snåla lite med anslutningarna.