I have been trying to pull information from different sources to learn
how to execute a stored procedure via a SqlConnection (not
OleDbConnection) and passing parameters to this stored procedure. I have
SQL Server 2000. Is there an example of how to exactly do this somewhere?
The resources I have only really use the OleDbConnection since it is a
generic way to connect to any datasource. This is frustrating. arrrggghhh
HERE IS MY ERROR MESSAGE:
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:
Line 16: ' dim ds as DataSet
Line 17:
Line 18: objCmd.InsertCommand.CommandType =
CommandType.StoredProcedure
Line 19: objCmd.InsertCommand.Parameters.Add
("@i_LoginId", "bgaines")
Line 20: objCmd.InsertCommand.Parameters.Add
("@i_Table", "CH_tbl_Test")
HERE IS MY CODE BASE:
sub Page_Load(Sender as Object, e as EventArgs)
end sub
sub InsertTest(Sender as Object, e as EventArgs)
dim strSqlConn as SqlConnection = new SqlConnection
("server=gaines-xe3-xp;initial catalog=ch_cust_spec_sample;user
id=sa;password=;")
dim objCmd as new SqlDataAdapter("CH_sp_Dynamic_Insert",
strSqlConn)
dim objParam as SqlParameter
objCmd.InsertCommand.CommandType = CommandType.StoredProcedure
objCmd.InsertCommand.Parameters.Add("@i_LoginId", "bgaines")
objCmd.InsertCommand.Parameters.Add("@i_Table", "CH_tbl_Test")
objCmd.InsertCommand.Parameters.Add
("@i_Column_List", "'name','notes','active_flag'")
objCmd.InsertCommand.Parameters.Add("@i_included_values","'Test
Name'|'Test this Name'|1")
strSqlConn.Open()
end sub
<form runat="server">
<asp:button id="submit" runat="server" Text="Submit"
OnClick="InsertTest" />
</form>