Prepared statement not supplied error

E

Elizabeth

I'm new to asp.net, so I hope I can explain the problem clearly.

I am getting the following error message:

Server Error in '/apps/ecards' Application.
--------------------------------------------------------------------------------

Prepared statement '(@msgID int,@randomVar int)SELECT msgID, fromName,
fromEmail, to' expects parameter @msgID, which was not supplied.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Prepared
statement '(@msgID int,@randomVar int)SELECT msgID, fromName,
fromEmail, to' expects parameter @msgID, which was not supplied.

Source Error:


Line 151:
Line 152: Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Line 153: SqlDataAdapter1.Fill(DataSet11)
Line 154: ToName.DataBind()
Line 155: FromName.DataBind()


Source File: C:\Program Files\Microsoft Content Management
Server\Server\exeres\applications\ecards\templates\show_ecards_flash_file.aspx.vb
Line: 153

Stack Trace:


[SqlException: Prepared statement '(@msgID int,@randomVar int)SELECT
msgID, fromName, fromEmail, to' expects parameter @msgID, which was
not supplied.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +643
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior) +9
System.Data.Common.DbDataAdapter.Fill(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
ecards.show_ecards_flash_file.Page_Load(Object sender, EventArgs e)
in C:\Program Files\Microsoft Content Management
Server\Server\exeres\applications\ecards\templates\show_ecards_flash_file.aspx.vb:153
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724
---------------------------------------------------

@msgID is a parameter and its value is set by the querystring. I'm
binding values to literals to display information from the SQL
database. This is the page load code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
eCardSqlCmd().Parameters("@msgID").Value =
(Request.QueryString("m"))
eCardSqlCmd().Parameters("@randomVar").Value =
(Request.QueryString("r"))

SqlDataAdapter1.Fill(DataSet11)
ToName.DataBind()
FromName.DataBind()
ToEmail.DataBind()
FromEmail.DataBind()
cardID.DataBind()
message.DataBind()
End Sub

Does anyone have any suggestions as to what could be causing the
problem?

Thanks.
 
M

Miha Markic

Hi Elizabeth,

Isn't a SQL structure like:
(@msgID int,@randomVar int)SELECT msgID, fromName, fromEmail,
a bit strange?
Also, from source line errors it is not obvious that you are binding
parameter values to anything.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com


Elizabeth said:
I'm new to asp.net, so I hope I can explain the problem clearly.

I am getting the following error message:

Server Error in '/apps/ecards' Application.
-------------------------------------------------------------------------- ------

Prepared statement '(@msgID int,@randomVar int)SELECT msgID, fromName,
fromEmail, to' expects parameter @msgID, which was not supplied.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Prepared
statement '(@msgID int,@randomVar int)SELECT msgID, fromName,
fromEmail, to' expects parameter @msgID, which was not supplied.

Source Error:


Line 151:
Line 152: Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Line 153: SqlDataAdapter1.Fill(DataSet11)
Line 154: ToName.DataBind()
Line 155: FromName.DataBind()


Source File: C:\Program Files\Microsoft Content Management
Server\Server\exeres\applications\ecards\templates\show_ecards_flash_file.as
px.vb
Line: 153

Stack Trace:


[SqlException: Prepared statement '(@msgID int,@randomVar int)SELECT
msgID, fromName, fromEmail, to' expects parameter @msgID, which was
not supplied.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +643
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(Comman
dBehavior
behavior) +9
System.Data.Common.DbDataAdapter.Fill(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
ecards.show_ecards_flash_file.Page_Load(Object sender, EventArgs e)
in C:\Program Files\Microsoft Content Management
Server\Server\exeres\applications\ecards\templates\show_ecards_flash_file.as
px.vb:153
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724
---------------------------------------------------

@msgID is a parameter and its value is set by the querystring. I'm
binding values to literals to display information from the SQL
database. This is the page load code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
eCardSqlCmd().Parameters("@msgID").Value =
(Request.QueryString("m"))
eCardSqlCmd().Parameters("@randomVar").Value =
(Request.QueryString("r"))

SqlDataAdapter1.Fill(DataSet11)
ToName.DataBind()
FromName.DataBind()
ToEmail.DataBind()
FromEmail.DataBind()
cardID.DataBind()
message.DataBind()
End Sub

Does anyone have any suggestions as to what could be causing the
problem?

Thanks.
 
E

Elizabeth

I've done some more digging into info about .Net and SQL and I changed
"eCardSqlCmd().Parameters("@randomVar").Value =
(Request.QueryString("r"))" to
"SqlDataAdapter1.SelectCommand.Parameters("@msgID").Value =
Request.QueryString("m")" and it's working now.

Does anyone have any recommendations for good sites/books that talk
about using .Net and SQL?

Thanks,
Elizabeth


Miha Markic said:
Hi Elizabeth,

Isn't a SQL structure like:
(@msgID int,@randomVar int)SELECT msgID, fromName, fromEmail,
a bit strange?
Also, from source line errors it is not obvious that you are binding
parameter values to anything.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com


Elizabeth said:
I'm new to asp.net, so I hope I can explain the problem clearly.

I am getting the following error message:

Server Error in '/apps/ecards' Application.
-------------------------------------------------------------------------- ------

Prepared statement '(@msgID int,@randomVar int)SELECT msgID, fromName,
fromEmail, to' expects parameter @msgID, which was not supplied.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Prepared
statement '(@msgID int,@randomVar int)SELECT msgID, fromName,
fromEmail, to' expects parameter @msgID, which was not supplied.

Source Error:


Line 151:
Line 152: Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Line 153: SqlDataAdapter1.Fill(DataSet11)
Line 154: ToName.DataBind()
Line 155: FromName.DataBind()


Source File: C:\Program Files\Microsoft Content Management
Server\Server\exeres\applications\ecards\templates\show_ecards_flash_file.as
px.vb
Line: 153

Stack Trace:


[SqlException: Prepared statement '(@msgID int,@randomVar int)SELECT
msgID, fromName, fromEmail, to' expects parameter @msgID, which was
not supplied.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +643
System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(Comman
dBehavior
behavior) +9
System.Data.Common.DbDataAdapter.Fill(Object data, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
ecards.show_ecards_flash_file.Page_Load(Object sender, EventArgs e)
in C:\Program Files\Microsoft Content Management
Server\Server\exeres\applications\ecards\templates\show_ecards_flash_file.as
px.vb:153
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724
---------------------------------------------------

@msgID is a parameter and its value is set by the querystring. I'm
binding values to literals to display information from the SQL
database. This is the page load code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
eCardSqlCmd().Parameters("@msgID").Value =
(Request.QueryString("m"))
eCardSqlCmd().Parameters("@randomVar").Value =
(Request.QueryString("r"))

SqlDataAdapter1.Fill(DataSet11)
ToName.DataBind()
FromName.DataBind()
ToEmail.DataBind()
FromEmail.DataBind()
cardID.DataBind()
message.DataBind()
End Sub

Does anyone have any suggestions as to what could be causing the
problem?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top