Hello Every One,
When i run my project i get Error "There is no row at position 0", please help.
Here is my code:
Private Sub PopulateDepartmentHead()
'Fill data in comboBox
Dim SqlDataAdapter As OleDbDataAdapter
Dim DSet As New DataSet
Dim strSelect As String
SQLConn.Close()
SQLConn.ConnectionString = oFunc.GetConnectionString(sINIFile)
'myConn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=" & strPath & "\" & strName & ".mdf" & ";Integrated Security=True;User Instance=True")
SQLConn.Open()
Try
strSelect = "SELECT * FROM dbo.hrEmployeeInformation"
SqlDataAdapter = New OleDbDataAdapter(strSelect, SQLConn)
DSet = New DataSet()
SqlDataAdapter.Fill(DSet)
Me.dhcboEmployeeSelect.DataSource = DSet.Tables(0)
Me.dhcboEmployeeSelect.ValueMember = "eiEmployeeID"
Me.dhcboEmployeeSelect.DisplayMember = "eiFirstName"
'MsgBox(Me.dhcboEmployeeSelect.DisplayMember = "Cust_ID")
SQLConn.Close()
Catch ex As Exception
MessageBox.Show("Error No : " & Err.Number & vbCrLf _
& "Error : " & ex.Message & vbCrLf _
& "Source : " & Err.Source & vbCrLf _
, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Code for selectindexchanged event:
Private Sub dhcboEmployeeSelect_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dhcboEmployeeSelect.SelectedIndexChanged
Dim SqlDataAdapter As OleDbDataAdapter
Dim custDataset As New DataSet
Dim strSelect As String
SQLConn.Close()
SQLConn.ConnectionString = oFunc.GetConnectionString(sINIFile)
SQLConn.Open()
Try
strSelect = "SELECT * FROM dbo.hrEmployeeInformation WHERE eiEmployeeID = '" & dhcboEmployeeSelect.Text & "'"
SqlDataAdapter = New OleDbDataAdapter(strSelect, SQLConn)
custDataset = New DataSet()
SqlDataAdapter.Fill(custDataset, "dbo.hrEmployeeInformation")
SqlDataAdapter.Dispose()
Dim custTable As DataTable = custDataset.Tables(0)
dhEmployeeID.Text = custTable.Rows(0).Item(0)
dhEmployeeName.Text = custTable.Rows(0).Item(1)
SQLConn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
SQLConn.Close()
End Try
End Sub
Code for Form Load:
Private Sub frmDepartmentHead_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
SQLConn.Close()
SQLConn.ConnectionString = oFunc.GetConnectionString(sINIFile)
FormName()
EnableControlsFormLoad(True)
SQLConn.Open()
ds.Clear()
SQLConn.Close()
'Fill Combo
PopulateDepartmentHead()
Catch ex As Exception
MessageBox.Show("Error No : " & Err.Number & vbCrLf _
& "Error : " & ex.Message & vbCrLf _
& "Source : " & Err.Source & vbCrLf _
, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
PLEASE HELP ME, WHERE DID I WENT WRONG....
Thanks