V
Venkatesh
Hi
I have a class with one property that gets/sets
IdataParameter as shown below
-----------------------------------------------------------
-
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Public Class BusDataCommand
Private marrCommandParameters() As IDataParameter
Private Const mstrNotSupported As String = "Only
Stored Procedures are supported"
Public Sub New()
End Sub 'New
#Region "Properties"
' Parameters Property
Public Property Parameters() As IDataParameter()
Get
Return marrCommandParameters
End Get
Set(ByVal Value As IDataParameter())
marrCommandParameters = Value
End Set
End Property
' TableName property
#End Region
End Class
___________________________________________________________
__
I then try to populate this class as shown below
-----------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As DataSet
Dim busDataCommand As New BusDataCommand
Dim arlTableName As ArrayList
Dim intArrayCount As Integer
Dim strParameter As IDataParameter
Dim arlindex As Integer
busDataCommand.Parameters(0).ParameterName = CStr
("@pUser")
busDataCommand.Parameters(0).Value = CStr("test")
arlCommands.Add(busDataCommand)
I get a system.nullreferenceexception at line:
busDataCommand.Parameters(0).ParameterName = CStr("@pUser")
What am I doing wrong ?
Thanks,
Venkatesh
I have a class with one property that gets/sets
IdataParameter as shown below
-----------------------------------------------------------
-
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections
Public Class BusDataCommand
Private marrCommandParameters() As IDataParameter
Private Const mstrNotSupported As String = "Only
Stored Procedures are supported"
Public Sub New()
End Sub 'New
#Region "Properties"
' Parameters Property
Public Property Parameters() As IDataParameter()
Get
Return marrCommandParameters
End Get
Set(ByVal Value As IDataParameter())
marrCommandParameters = Value
End Set
End Property
' TableName property
#End Region
End Class
___________________________________________________________
__
I then try to populate this class as shown below
-----------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As DataSet
Dim busDataCommand As New BusDataCommand
Dim arlTableName As ArrayList
Dim intArrayCount As Integer
Dim strParameter As IDataParameter
Dim arlindex As Integer
busDataCommand.Parameters(0).ParameterName = CStr
("@pUser")
busDataCommand.Parameters(0).Value = CStr("test")
arlCommands.Add(busDataCommand)
I get a system.nullreferenceexception at line:
busDataCommand.Parameters(0).ParameterName = CStr("@pUser")
What am I doing wrong ?
Thanks,
Venkatesh