开发者

linq to mySQL How can I trick VB Express to use it?

开发者 https://www.devze.com 2023-01-29 02:04 出处:网络
I\'m currently using VB.NET Express to connect to mySQL over the net. No problem as long as I use plain vanilla SQL connections an开发者_如何学Cd statements.

I'm currently using VB.NET Express to connect to mySQL over the net. No problem as long as I use plain vanilla SQL connections an开发者_如何学Cd statements.

But when it comes to LINQ 2 mySql, I'm struck by VB Express's limitation.

Any clue you gurus?


You'll need to switch out to using something like DBLinq, Entity Framework, or nHibernate instead of Linq-to-SQL. Linq-to-SQL only supports SQL Server and SQL Server CE. This isn't a limitation of Visual Studio Express at all. Actually, the only limitations I know of with the express editions are that they don't support any Visual Studio plug-ins - but as far as CLR features, you aren't limited at all using Express. And, Entity Framework is built-in and available for you to use out of the box. And stackoverflow has info on the MySQL connector.


After a couple of days searching, Iv' finally reached the Saint Graal!

Since you guys at StackOverflow are so great a bunch of blokes, I've written a little how to sample for you. Here it is:

1 - The ONLY sensible, free and working product I've founr is Devart LinqConnect Express edition.

Its a free product from www.devart.com, capable of:

(Please note I have no particular links nor interest with them.)

  • Generating datacontext from its own embarked Devart EntityDeveloper free edition (With some limits in number of tables per context, 10 if I'm right).

  • Complete the LINQ dlls into Visual Basic Express edition, without having to create a datasource from the datasource explorer.

Ok, once you've installed the package, here's the how to:

Launch the Entity designer from Program Files\Devart LinqConnect and create the model from the database.

Save the model and launch your VB Winform project.

Add the following .NET references:

Devart.Data.Linq
Devart.Data.MySql.Linq      '-- Or any other DB you need
System.Data.Linq

Now add the new datacontext.designer.vb file you've created in Entity Developer to the project:

Right-click the project in Solution Explorer and select

Add existing item
Locate the datacontext file and that's almost it!

Create a button and a datagridview named dgv1 onto your form. 5 more lines of code and you're set!

Button code:

Dim ctx As New myDataContext.myDataContext

Using ctx
    Dim tbl = From xxx In ctx.myTable
                    Select xxx

    dgv1.DataSource = xxx.ToList
End Using

The rest is pure cosmetic LOL...

It is worth to mention that although their product is great, the support is great as well! They answered my questions in less than 12 hours.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号