I’ve got some information in a database that I want to drop in “Notes”.
Is it possible to use System.data.OleDb.OleDbConnection?

I’m trying to do this with:

Dim con As New OleDb.OleDbConnection
Dim da As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
Dim sql As String
Dim dbProvider As String
Dim dbSource As String
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
Dim source As String = App_Path & "\Settings\AddressBook.mdb"
dbSource = "Data Source = " & source
con.ConnectionString = dbProvider & dbSource
sql = “select * FROM tblcontacts WHERE Voornaam = '” & voornaam & “’ AND ACHTERNAAM = '” & achternaam & “’ AND GEBOORTEDATUM = '” & geboortedatum & "’"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, “AddressBook”)
Dim notes = ds.Tables(“AddressBook”).Rows(0).Item(“Notes”)
RhinoDoc.ActiveDoc.Notes = notes

Some words are in Dutch but I think its clear what i mean but it is not working. I checked the location of the database and it’s on the right position. Also the select * FROM tblcontacts WHERE Voornaam = ‘" & voornaam & "’ AND ACHTERNAAM = ‘" & achternaam & "’ AND GEBOORTEDATUM = ‘" & geboortedatum & "’" should also be right because I’m using this somewhere else too this way.

Any tips?

  • Jordy

One possibility that comes to mind is that your command strings are not actually being assembled the way you intended. Have you tried putting a Debug.Print before the con.ConnectionString= and after the sql= statements? When I do this I like to use the form Debug.Print(“DebugOutputLabel = |” & StringToCheckFormatOf & “|”). The vertical bars will delimit the exact start and finish of the string being checked so as to clearly show any leading and trailing spaces. It might be useful to check whether the database is open and accessible by just printing out con.recordcount or other database property that doesn’t need a select statement right after you open it.

I’ll test it when I’m behind my own computer. Thanks for the fast reply.
Btw. Rhino doesnt automatticly load the system.data.dll can the problem have to do with this?

What do you mean that Rhino doesn’t automatically load System.Data.Dll? That should get loaded when first needed by the .NET framework.

well if I only load OleDb.OleDbConnection it will not get recognized in need to Imports System.Data first and add the dll by hand.
should it work then?

Sorry, I don’t understand your question. Could you explain a little more?

well I use the code above exactly the same in a normal form and it works. Now I try to use it in a command and it doesnt.
Same select conditions and everything but nothing :frowning:

So my question really is:

Do you guys see something wrong here?
And is it possible to use OleDb in a plug-in?

@AlW it doenst print anything after SQL maybe the con.open() bugs?

Having the code run in Rhino should not make a difference. Does Visual Studio give you any information about the error when you run the code in the debugger? Is an exception thrown or does your code just silently fail?

Can’t debug because of this error but the Rhino.exe is on that location.

But I can built it without a problem. Then I just drag it into Rhino. Run my command and nothing after con.open().
If I put a msgbox(“hi”) before it it will show. After. Nothing. So it seems it can’t open the connectionstring. I’ve checked the location where it should open and it’s good (PROVIDER=Microsoft.Jet.OLEDB.4.0; C:\AddressBook.mdb) Just coppied it to C:/ to be sure and changed the “select * FROM tblcontacts WHERE Voornaam = ‘Niels’” to something simpler to test. Nothing :frowning:

I would highly recommend getting the debugger to work before attempting anything else. Debugging by placing message boxes and print statements in the code is going to slow and painful.

The path used to start the debugger appears to be incorrect for your system. Try opening the .user file for your project and locate the path to the Rhino.exe make sure this matches what is on your computer. Make these edits while visual studio and rhino are closed.

I don’t have a copy of VB express installed at the moment or I would have a better description of the steps needed.

where can I find the .user file?

It should be right next to your vbproj file

Oke debugger works now. It opens rhino and then I have to type my command to run it.

It does say that a breakpoint cant be hit because no symbols loaded for this document…
dont know what that means

OleDb nothing yet

Can you hit breakpoints in your RunCommand? This message may be referring to not being able to debug into the core rhino application.

I can put a red dot before it to debug where the command stops normally when I program. But now it doesnt do anything. The red dot appears then : breakpoint cant be hit because no symbols loaded for this document…

Are you building your plug-in for .NET 4? If not, you should change your runtime to .NET 4. That can cause the debugger to get confused and not be able to hit breakpoints.

Rhino .net 4 yes

I’m not sure what the word Rhino meant in your last comment, but I’m assuming that you mean “yes, my plug-in project is targeting .NET framework 4”

The other thing to check is to make sure you are building a “Debug” build of your plug-in and not a “Release” build.

I click on top > Debug > start debugging so i think im debugging :stuck_out_tongue: