Want to change IDbconnection servicestack. Ormlite MySQL becomes dapper with MSACESS in Vb. Net
Project detail
Dear All,
I want the code below to be changed to dapper with database access on vb.net. The code below uses ServiceStack.OrmLite and Kimtoo.DbContext with mysql database. My goal is to be able to use kimtoo datagridview binding provider with dapper database access
Thanks
‘Module Connection
Imports Kimtoo.DbContext
Imports ServiceStack.OrmLite
Imports MySql
Imports ServiceStack
Namespace DGVBindingImages.Data
Public Module Connection
‘constructor
Sub New()
Try
‘setttings for mysql
Dim err = Db.Init(“Server=localhost;Database=demo;Uid=root;SslMode=none;”, MySqlDialect.Provider)
‘settings for sql server
‘var err = Db.Init(@”Server=admin-PCLOCALHOST;Database=demo;Trusted_Connection=True;”, SqlServerDialect.Provider);
If err IsNot Nothing Then
MessageBox.Show(err.Message)
Environment.Exit(0)
End If
Catch err As Exception
MessageBox.Show(err.Message)
Environment.Exit(0)
End Try
End Sub
Public Sub CheckAndCreateTables()
Dim db As System.Data.IDbConnection = Kimtoo.DbContext.Db.Get()
db.CreateTableIfNotExists(Of User)()
End Sub
End Module
End Namespace
‘in form1 or form main
Public Sub New()
InitializeComponent()
grid.OnEdit(Of User)(Function(r, c) Db.Get().Save(r) OrElse True)
LoadData()
End Sub