By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,562 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

Getting not declared Error

P: n/a
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;Da ta 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").Defa ultView
oGrid.DataBind()
End Sub
Mar 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

Mar 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.