Using recordsets with MySQLConnection objects - VB.NET

619 views Asked by At

I'm trying to port a program from Excel to a standalone executable, using VB.NEt as my programming language. However, my previous method of ADODB Connections and recordsets doesn't seem to work here, so I've had to switch to a MySQLConnection instead. I've got a connection up and running, but now I'm left without an ADODB recordset, since it doesn't accept the MySQLConnection object as a valid argument.

Here is how I make my connection:

Dim oConn = New MySqlConnection
oConn.ConnectionString = "Data Source=*********.****.com;Port=3306;Initial Catalog=" + database + ";User id=" + username + ";Password=" + password + ";"
oConn.Open()

And here is how I attempt to use my recordset:

Dim rs = New ADODB.Recordset
Dim strSql = "select first_name, last_name, group_id, id, accomidations, enabled from attendees where " & _
        " first_name LIKE '" + Trim(CStr(HotelInfoForm.NameTextBox.Text)) + "%' Or" & _
        " last_name LIKE '" + Trim(CStr(HotelInfoForm.NameTextBox.Text)) + "%' order by last_name"
rs.Open(strSql, oConn)

When I reach rs.Open, the program crashes, giving me this:

"ComException was unhandled - Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."

Again, i'm almost positive it's because I'm trying to use a MySQL object as an argument, but I'm not 100% sure. Can anyone tell me if that is the case, and if so, how I might go about fixing this?

0

There are 0 answers