Getting not declared Error

M

momo

Can some take a look at this and tell me what I am doing wrong and how to
fix it. I an new to ASP.NET

Getting Name "GetMsAccessOldebConnection' is not declared " Error



<%@ Page language="VB" Debug="false" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">

public shared function GetMsAccessOledbConnection(ByVal dbPath As String,
ByVal dbID As String, ByVal dbPassword As String)
Dim dbConn As OleDbConnection
Dim dbConnStr As String =
String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};User
ID={1};Password={2}", dbPath, dbID, dbPassword)
return new OleDbConnection(dbConnStr)
End function

Sub Page_Load(Sender as Object, E as EventArgs)
Dim oConn As OleDbConnection
Dim oComm As OleDbDataAdapter
Dim sConn As String
Dim sComm As String
Dim oDataSet As New DataSet
dim Pathdb as String
Pathdb = String.Format(server.mappath("reports/db/specialk.mdb"))

sComm = "Select LastName, FirstName, Phone FROM tblEmployeeChecklist
where ActiveStatus=" & "Yes"' & "'"

'Usually you would use error-handling here. It is left out to
'make the code as simple as possible.

'Create the connection and command objects
oConn = GetMsAccessOledbConnection(Pathdb, "admin", "")
oComm = New OleDbDataAdapter(sComm, oConn)

'Fill the dataset with the results of the query
oComm.Fill(oDataSet, "Employees")

'Set the grid source to the dataset and bind the data
oGrid.DataSource=oDataSet.Tables("Employees").DefaultView
oGrid.DataBind()
End Sub
 
J

Jacob

You should probably start by changing your function declaration to:
public shared function GetMsAccessOledbConnection(ByVal dbPath As
String,
ByVal dbID As String, ByVal dbPassword As String) As OleDbConnection
otherwise it returns an object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top