2

It has been way to long since I have been involved in VB so I need some help here. I have the following in my C# code

SqlParameter[] param = new SqlParameter[0];
 ...some code...
param = new SqlParameter[2];
param[0] = db.MakeInputParameter("@group_id", groupid);
param[1] = db.MakeInputParameter("@organization_id", orgid);

The reason i do not initialize the size firstly is because i reuse the param variable in the same method, just in case you were wondering

The following is what I have tried but I keep getting that the variable is used before I assign a value

Dim param() As SqlParameter
...some code...
param(2) = New SqlParameter
param(0) = db.MakeInputParameter("@group_id", groupid)
param(1) = db.MakeInputParameter("@organization_id", orgid)

How do I convert this type of logic to VB.Net

KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
mattgcon
  • 4,768
  • 19
  • 69
  • 117

1 Answers1

2

Use ReDim

Dim param() As SqlParameter
Redim param(1) 'The value VB.NET array subscript uses upper-bound.

Or

param = New SqlParameter(1) {}
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186