ExecuteProc
Private
Sub ExecuteProc(ByVal ProcName As String)
Dim helper As New ParmHelper
'helper.AddParm("@PartNumber", GetAllPartNumbers, SqlDbType.NChar, 50)
'helper.AddParm("@CustomerName", CustomerName.Trim(" "), SqlDbType.NChar, 100)
helper.AddParm(
"@CustomerName", "carrier 62e", SqlDbType.NChar, 100)
helper.AddParm(
"@PartNumber", "CCCC--XR61-ra", SqlDbType.NChar, 50)
Dim ds = ExecuteDataSet(ProcName, CommandType.StoredProcedure, helper.GetAllParm)
Try
Dim Qty As String = ""
Dim Desc As String = ""
Dim Boms As String = ""
If ds.Tables.Count = 1 Then 'my program gets this far sees a 1 table
Debug.Print(ds.Tables(0).Rows.Count) 'however this returns zero rows
Debug.Print(ds.Tables(0).Rows(0)(0).ToString)
Debug.Print(CustomerName)
For I As Integer = 0 To ds.Tables(0).Rows.Count - 1
Boms = ds.Tables(0).Rows(I)(0).ToString
Desc = ds.Tables(0).Rows(I)(1).ToString
Qty = ds.Tables(0).Rows(I)(2).ToString
Dim lstItm As ListViewItem = ListView1.Items.Add(Qty)
lstItm.SubItems.Add(Boms)
lstItm.SubItems.Add(Desc)
Next
Else
If (ds.Tables(0).Rows.Count > 0) Then
Boms = ds.Tables(0).Rows(0)(0).ToString
End If
If (ds.Tables(1).Rows.Count > 0) Then
Desc = ds.Tables(1).Rows(0)(0).ToString
End If
If (ds.Tables(2).Rows.Count > 0) Then
Qty = ds.Tables(2).Rows(0)(0).ToString
End If
'Dim lstItm As ListViewItem =
Dim lstItm As ListViewItem = ListView1.Items.Add(Qty)
lstItm.SubItems.Add(Boms)
lstItm.SubItems.Add(Desc)
End If
Catch Ex As Exception
Debug.Print(
"Error" & vbCrLf & Ex.Message)
MsgBox(
"Error" & vbCrLf & Ex.Message)
End Try
End Sub
Here is my code for ExecuteDataSet
Public
Function ExecuteDataSet(ByVal Sql As String, ByVal SqlCmdType As CommandType) As DataSet
Return ExecuteDataSet(Sql, SqlCmdType, Nothing)
End Function
Public Function ExecuteDataSet(ByVal Sql As String, ByVal SqlCmdType As CommandType, ByVal Parms As List(Of SqlParameter)) As DataSet
Dim con As SqlConnection = GetConnection()
Dim cmd As New SqlCommand(Sql, con)
cmd.CommandType = SqlCmdType
LoadParms(cmd, Parms)
Try
Dim Sda As New SqlDataAdapter(cmd)'both command and connection look good.
Dim ds As New DataSet
Sda.Fill(ds)'program seems to do this step twice not sure what that means.
Return ds
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return Nothing
End Function