By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

A first chance exception of type 'System.Reflection.AmbiguousMatchException' occurred

P: 12
Please help i got a problem in visual basic .net and im using visual studio 2010
when I run program to display records from database to listview i encountered a problem in immediate window and it says:

A first chance exception of type 'System.Reflection.AmbiguousMatchException' occurred in Microsoft.VisualBasic.dll

I encountered that problem when one of my data field in recordset is null and the program doesn't display accurately

here is my code:

Expand|Select|Wrap|Line Numbers
  1. Public cn As New MySqlConnection
  2.     Public recurring As String
  3.  
  4.  
  5.     Public Sub LoadEvents()
  6.         On Error Resume Next
  7.         Dim str_2 As String = "SELECT * FROM tbl_event ORDER BY Date"
  8.         Dim rsEvent As New MySqlDataAdapter
  9.         Dim SQLCommand As New MySqlCommand
  10.         Dim TABLE As New DataTable
  11.         Dim i As Integer
  12.  
  13.         With SQLCommand
  14.             .CommandText = str_2
  15.             .Connection = cn
  16.         End With
  17.  
  18.         With rsEvent
  19.             .SelectCommand = SQLCommand
  20.             .Fill(TABLE)
  21.         End With
  22.  
  23.         LVEvList.Items.Clear()
  24.  
  25.         For i = 0 To TABLE.Rows.Count - 1
  26.             With LVEvList
  27.                 .Items.Add(TABLE.Rows(i)("ID"))
  28.                 With .Items(.Items.Count - 1).SubItems
  29.                     .Add(TABLE.Rows(i)("Event_Name"))
  30.                     .Add(TABLE.Rows(i)("Venue"))
  31.                     .Add("" & Format(TABLE.Rows(i)("Date"), "MMM dd, yyyy"))
  32.                     .Add("" & Format(TABLE.Rows(i)("Time"), "Long Time"))
  33.                     .Add(TABLE.Rows(i)("Category"))
  34.                     .Add(TABLE.Rows(i)("Recurring"))
  35.                 End With
  36.             End With
  37.         Next i
  38.     End Sub
  39.  
  40.     Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  41.         If cn.State = ConnectionState.Closed Then
  42.             cn.ConnectionString = "SERVER = localhost; USERID = root; PASSWORD=; DATABASE = clsf_member_information;"
  43.             cn.Open()
  44.             LoadEvents()
  45.         End If
  46.     End Sub
please help to resolve this problem thanks
May 25 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.

Browse more Visual Basic .NET Questions on Bytes