这是另外张帖子http://community.csdn.net/Expert/topic/4278/4278299.xml?temp=.5989038求大虾解答.
下面的是我的文件. 出错主要是在 Server.mappath()这里
'====== form.aspx =====
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub    Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ServerClick
'建立实例
        Dim ObjAddInfo As New Taojin.FormSqlCmd
'
        ObjAddInfo.addinfo(StrUser.Value, UsrChgPay.Value, ReqChgPay.Value, _
        TxtUsrInfo.Value, IntUsrCme.Value, IntReqCme.Value)
        StrLabInFo.Text = "加入数据成功!"
    End Sub
' ========= End ===========
' ============ FormSqlCmd 类文件 ===============
Public Class FormSqlCmd
    Dim StrConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" ****'就这里不知道怎么写了。***
    ' Server.MapPath("data/Tj_data.mdb") 应该放哪儿?    Dim ObjConn As OleDb.OleDbConnection = New OleDb.OleDbConnection(StrConn)
    Dim ObjCommand As New OleDb.OleDbCommand
    '加入数据操作
    Function addinfo(ByVal StrUser As String, ByVal StrUcp As String, ByVal StrRcp As String, _
    ByVal StrTxt As String, ByVal IntUsrCme As String, ByVal IntReqCme As String)
        Dim Sql As String = "insert into TxtInformation Values('" + StrUser + "','" + StrUcp + "','" + StrRcp + "','" + StrTxt + "','" + IntUsrCme + "','" + IntReqCme + "')"
        ObjConn.Open()
        ObjCommand.Connection = ObjConn
        Try
            ObjCommand.CommandText = Sql
            ObjCommand.ExecuteNonQuery()
        Catch ex As Exception
            Return False
        End Try
    End Function
    Sub FormSqlCmd(ByVal StrConn As String) '初始化
    End Sub
End Class
================ End ======================麻烦各位大虾帮忙看看了.

解决方案 »

  1.   

    放在函数里面,要么用个变量存储 Server.MapPath("data/Tj_data.mdb")
      

  2.   

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data/Tj_data.mdb")
      

  3.   

    先谢谢 1楼,2楼 ,但这些方法我都试过,好象行不通挨.
    =========================================================================adventure007(adventure):FormSqlCmd你这个可定是找不到server.mappth的!没有继承page类!
    不要在封装的类中具体出现文件名,等你调用的时候传入实际的参数不久ok了吗=========================================================================有人知道怎么调用吗?
      

  4.   

    我试了下.这样可以用,但还是在封装的类中出现了文件名.Dim StrConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\data\Tj_data.mdb"
      

  5.   

    C#.net 里面可以这样HttpContext.Current.Server.MapPath
      

  6.   

    现在不提示出错了但又出问题了数据写入不了access数据库了求助啊...
      

  7.   

    文件夹只读了,还是ASP.NET用户无权限(请注意查看一下权限)
      

  8.   

    没必要everyone
    只需要asp.net用户可以控制就可以了