I have an access database (mco.mdb) with a table tblA. Using a windows form (from visual studio 2005) and a datagridview I want to display the contents of tblA.
I use the following code in the load event of the form as test.
This works without a problem. Now I want to write a user defined function in the sql statement. For example:
sql = "select ID, description, fTest() as new_column_name from tblA"
When I run the form I receive the error "Undefined function fTest in expression". This is normal because I haven't written this function yet.
But how do I have to write this function? If I use following code (like a normal function in vb.net) I still receive the error. If I use the debugger, I see this function never get accessed.
So, next to the columns ID and Description I want to see the column "new_column_name" with "abc" in it for every value. This is just for testing purpose. Eventually this column has to receive a calculation depending from some other criteria...
Does anybody know how to solve this problem? I'm already stuck on it for several days... : (
I use the following code in the load event of the form as test.
VB.NET:
Dim strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=mco.mdb"
Dim objConnection As OleDbConnection = New OleDbConnection(strConnection)
Dim objDataAdapter As OleDbDataAdapter
Dim objDataset As DataSet
dim sql as String = "select ID, description from tblA"
objConnection.Open()
objDataadapter = New OleDbDataAdapter(sql, objConnection)
objDataset = New DataSet("MCO")
objDataAdapter.Fill(objDataset, "A")
objConnection.Close()
DataGridView1.DataSource = objDataset.Tables("A")
This works without a problem. Now I want to write a user defined function in the sql statement. For example:
sql = "select ID, description, fTest() as new_column_name from tblA"
When I run the form I receive the error "Undefined function fTest in expression". This is normal because I haven't written this function yet.
But how do I have to write this function? If I use following code (like a normal function in vb.net) I still receive the error. If I use the debugger, I see this function never get accessed.
VB.NET:
Public Function fTest() as string
return "abc"
end function
So, next to the columns ID and Description I want to see the column "new_column_name" with "abc" in it for every value. This is just for testing purpose. Eventually this column has to receive a calculation depending from some other criteria...
Does anybody know how to solve this problem? I'm already stuck on it for several days... : (