My database access methods are in class file. This file is has a separate project name: Usr_mysqladapter. In another website project I import the class file as a dll and call the function in the class file by creating an object.
The class file contains the following function:
Public Function readfunctioid(ByVal query As String) As DataTable
Try
connecttodb()
mysqlcmd = New MySqlCommand(query, con)
da = New MySqlDataAdapter(mysqlcmd)
dt = New DataTable
da.Fill(dt)
Catch ex As Exception
Throw ex
Finally
disconnect()
End Try
Return dt
End Function
The website projects imports the dll as follows:
Imports Usr_mysqladapter
Dim obj As Usr_mysqladapter.Class1 = New Usr_mysqladapter.Class1
My button click calls the function like this:
dt = obj.readfunctioid("select fld_functionid from tbl_users_function_permission")
Unfortunately, I am getting error. How do I access the function in the class file from my website project?
In your website project simply do like…..
This is when your class is CALLED MyCustomClass
And the INSTANCE is called MyCustomSqlAdapter
Then in button do like….