Results 1 to 2 of 2

Thread: Class and Server.MapPath

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Question Class and Server.MapPath

    I have created a class which makes a database connection. I receive an error when I use Server.MapPath and I don't understand this. Why can this bed? Do I have to import a namespace or ...?
    Code:
    Imports System.Data
    Imports System.Data.OleDb
    Public Class clsMedieroer : Inherits clsMateriale
        Private _medie As Integer
        Private _medie1 As Integer
    
        Sub New(ByVal s As Integer, ByVal m As String)
            MyBase.New(m)
            Medie = s
        End Sub
    
        Public Sub FindMedie()
            Dim myDataset As New DataSet()
    
            Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=" & server.mappath("exceltest.xls") & ";" & _
            "Extended Properties=Excel 8.0;"
    
            Dim myData As New OledbDataAdapter("SELECT * FROM [Sheet1$] WHERE Id=2", strConn)
            myData.TableMappings.Add("Table", "ExcelTest")
    
         
            Select Case _medieroer
                Case Is = "St. 37.0 Konti"
                    _medie1 = 15
                Case Else
                    _medie1 = _medie
            End Select
        End Sub
    
        Public ReadOnly Property Medie1() As Integer
            Get
                Return _medie1
            End Get
        End Property
    
        Public WriteOnly Property Medie() As Integer
            Set(ByVal Value As Integer)
                _medie = Value
                FindMedie()
            End Set
        End Property
    
    End Class

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    System.Web.HttpContext.Current.Server.MapPath
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width