Error while passing input parameters to stored procedure using DAA

G

Guest

Hi,
I am trying to insert parameters into a stored procedure using DAAB (see
code at the bottom of this post). I am getting the following error:
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an
object.]
Microsoft.ApplicationBlocks.Data.SqlHelper.AttachParameters(SqlCommand
command, SqlParameter[] commandParameters)
Microsoft.ApplicationBlocks.Data.SqlHelper.PrepareCommand(SqlCommand
command, SqlConnection connection, SqlTransaction transaction, CommandType
commandType, String commandText, SqlParameter[] commandParameters)
Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(SqlConnection
connection, CommandType commandType, String commandText, SqlParameter[]
commandParameters)
Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String
connectionString, CommandType commandType, String commandText, SqlParameter[]
commandParameters)


Code:



Dim Params As SqlParameter() = New SqlParameter(2) {}
Params(0) = New SqlParameter("@title", SqlDbType.VarChar)
Params(0).Value = AdoFunc.FixTick(txtTitle.Text)
Params(1) = New SqlParameter("@body", SqlDbType.VarChar)
Params(1).Value = AdoFunc.FixTick(txtBody.Text)


SqlHelper.ExecuteNonQuery(AppSettings.Get("myconnection"),
CommandType.StoredProcedure, "insert_data", Params)

Stored procedure:
CREATE PROCEDURE insert_data
(
@title as varchar(100),
@body as varchar(600)

)
AS

insert into motivation_products(title,body) values('@title','@body')
 

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

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top