....mdb" is not a valid virtual path. but it's is there.

Last post 01-17-2007, 6:10 PM by aero. 10 replies.
Sort Posts: Previous Next
  •  01-14-2007, 7:03 AM 25774

    ....mdb" is not a valid virtual path. but it's is there.

    Hi.
     
    I have edit the database-example.aspx so the names match my tabels and so on but when i changes the: LINE 130
     conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Context.Server.MapPath("../uploads/Northwind.mdb") + ";"
    to
    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Context.Server.MapPath("d:/web/localuser/domain.dk/database/mybase.mdb") + ";"
    or to
    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Context.Server.MapPath("d:\web\localuser\domain.dk\database\mybase.mdb") + ";"
     
    Hope someone can help me with this.
     
    The error i get is:

    'd:/web/localuser/domain.dk/database/mybase.mdb' is not a valid virtual path.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: 'd:/web/localuser/domain.dk/database/mybase.mdb' is not a valid virtual path.
  •  01-14-2007, 4:39 PM 25779 in reply to 25774

    Re: ....mdb" is not a valid virtual path. but it's is there.

  •  01-16-2007, 6:24 PM 25837 in reply to 25779

    Re: ....mdb" is not a valid virtual path. but it's is there.

    Hi Adam
     
    The file structure is like this, and i cant place the database in another folder bc of security.
     
    d:/
      -web/
         -localuser/
             -domain.dk/
                 -database/
                     -mybase.mdb
                 -public_html/
                     -CuteSoft_Client/
                     -Upload/
                     -Bin/
                     -Templates/
                     -vb/
                         -mydatabaseconnsite.aspx
     
    hope this can help.
  •  01-17-2007, 11:03 AM 25856 in reply to 25779

    Re: ....mdb" is not a valid virtual path. but it's is there.

    can u help me with this !?
  •  01-17-2007, 11:09 AM 25857 in reply to 25837

    Re: ....mdb" is not a valid virtual path. but it's is there.

    Which one is the virtual directory?
     
    How do you access your site through URL?
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  01-17-2007, 12:33 PM 25861 in reply to 25857

    Re: ....mdb" is not a valid virtual path. but it's is there.

    the database folder is the folder for the database, and this folder is on same level as the public_html.
     
    the virtual directory for the site is then the public_html folder, bc the database isent in the same og under the public_html folder is bc. of security risens im hosted af www.unoeuro.dk.
     
    how to access to my site.... www.domain.dk or http://www.domain.dk .
    hope this helps. 
  •  01-17-2007, 12:57 PM 25863 in reply to 25861

    Re: ....mdb" is not a valid virtual path. but it's is there.

    Change
     
    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Context.Server.MapPath("d:/web/localuser/domain.dk/database/mybase.mdb") + ";"
     
    to
     
    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""d:/web/localuser/domain.dk/database/mybase.mdb"";"
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  01-17-2007, 1:12 PM 25864 in reply to 25863

    Re: ....mdb" is not a valid virtual path. but it's is there.

    if i changes that code i get this error
     
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

    Source Error:

    Line 75: Dim objDR as OleDbDataReader
    Line 76: Dim Cmd as New OleDbCommand(sql, conn)
    Line 77: objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    Line 78: MyDataGrid.DataSource = objDR
    Line 79: MyDataGrid.DataBind()

    and i know i have 3 recordes in my DB
  •  01-17-2007, 1:24 PM 25865 in reply to 25864

    Re: ....mdb" is not a valid virtual path. but it's is there.

    aero,
     
    Please post your whole code or use the following example as reference to debug your code:
     
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  01-17-2007, 1:49 PM 25866 in reply to 25865

    Re: ....mdb" is not a valid virtual path. but it's is there.

    Code is:
     

    <%@ Page Language="vb" Debug="true"%>

    <%@ Import Namespace="System.Data" %>

    <%@ Import Namespace="System.Data.OleDb" %>

    <%@ Register TagPrefix="cutesoft" TagName="banner" Src="banner.ascx" %>

    <%@ Register TagPrefix="cutesoft" TagName="leftmenu" Src="leftmenu.ascx" %>

    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>

    <html>

    <head>

    <title>ASP and ASP.NET WYSIWYG Editor - Database Example</title>

    <link rel="stylesheet" href="../example.css" type="text/css" />

    </head>

    <body>

    <form runat="server">

    <cutesoft:banner id="banner1" runat="server" />

    <table border="0" cellpadding="0" cellspacing="0">

    <tr>

    <td width=10 nowrap></td>

    <td valign="top" nowrap id="leftcolumn" width="160">

    <cutesoft:leftmenu id="leftmenu1" runat="server" />

    </td>

    <td width="20" nowrap></td>

    <td valign="top" width="760">

    <b>Database Example</b>

    <hr>

    This example show you how easy it can be to save the CuteEditor's content in a database.

    <br><br>

    <asp:Datagrid runat="server"

    Id="MyDataGrid"

    cellpadding="3"

    cellspacing="0"

    Headerstyle-BackColor="#eeeeee"

    Headerstyle-Font-Bold="True"

    BackColor="#f5f5f5"

    BorderWidth="1"

    Width=720

    Font-Name="Arial"

    Font-Size="12px"

    BorderColor="#999999"

    AutogenerateColumns="False"

    OnItemCommand="UpdateItem"

    >

    <Columns>

    <asp:BoundColumn DataField="EventID" Visible="False" />

    <asp:BoundColumn ItemStyle-Width="50px" DataField="SiteMainID" HeaderText="ID" />

    <asp:BoundColumn ItemStyle-Width="120px" DataField="SiteMainIdentity" HeaderText="Text" />

    <asp:BoundColumn ItemStyle-Width="430px" DataField="SiteMainText" HeaderText="Note" />

    <asp:ButtonColumn ItemStyle-Width="50px" ButtonType="LinkButton" CommandName="Edit" HeaderText="Edit" Text="Edit" />

    <asp:ButtonColumn ItemStyle-Width="50px" ButtonType="LinkButton" CommandName="Delete" HeaderText="Delete" Text="Delete" />

    </Columns>

    </asp:datagrid>

    <br>

    <CE:Editor id="Editor1" EditorWysiwygModeCss="../example.css" Autoconfigure="Simple" Height="200" runat="server" ></CE:Editor><br />

    <asp:Button id="btnUpdate" onclick="Submit" Runat="server" Text="Add"></asp:Button>

    <asp:Literal ID="Literal1" Runat="server" />

    <br><br>

    <input type="hidden" name="eventid" runat="server" id="eventid">

    </td>

    <tr>

    </table>

    </form>

    </body>

    </html>

    <script runat="server">

    Sub Page_Load(Source as Object, E as EventArgs)

    if not Page.IsPostBack then

    BindData

    end if

    End Sub

     

    Sub BindData()

    Dim sql as string = "SELECT SiteMainID, SiteMainIdentity, SiteMainText FROM MainSiteText"

    Dim conn As OleDbConnection = CreateConnection()

    Dim objDR as OleDbDataReader

    Dim Cmd as New OleDbCommand(sql, conn)

    objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)

    MyDataGrid.DataSource = objDR

    MyDataGrid.DataBind()

    End Sub

     

    Sub UpdateItem(s As Object, e As DataGridCommandEventArgs )

    Dim conn As OleDbConnection = CreateConnection()

     

    'Check if the CommandName==Delete

    If e.CommandName = "Delete" Then

    Dim com As OleDbCommand = New OleDbCommand("DELETE FROM MainSiteText WHERE SiteMainID = @id", conn)

    com.Parameters.Add("id", e.Item.Cells(0).Text)

    com.ExecuteNonQuery()

    conn.Close()

    else If (e.CommandName = "Edit") then

    Dim com As OleDbCommand = New OleDbCommand("SELECT SiteMainText FROM MainSiteText WHERE SiteMainID = @id", conn)

    com.Parameters.Add("id", e.Item.Cells(0).Text)

    Dim result As OleDbDataReader = com.ExecuteReader()

    If result.Read() Then

    'set the editor text

    Editor1.Text = result.GetString(0)

    eventid.Value = e.Item.Cells(0).Text

    btnUpdate.Text="Update"

    Else

    Editor1.Text = ""

    eventid.Value = ""

    btnUpdate.Text="Add"

    End If

    result.Close()

    End If

    BindData

    End Sub

     

    Sub Submit(s As Object, e As System.EventArgs )

    Dim conn As OleDbConnection = CreateConnection()

    Dim com As OleDbCommand = Nothing

    If Not eventid.Value = String.Empty Then

    com = New OleDbCommand("UPDATE MainSiteText SET SiteMainText = @content WHERE SiteMainID = @id", conn)

    com.Parameters.Add("content", Editor1.Text)

    com.Parameters.Add("id", Convert.ToInt32(eventid.Value))

    Else

    com = New OleDbCommand("INSERT INTO MainSiteText (Notes) VALUES (@content)", conn)

    com.Parameters.Add("content", Editor1.Text)

    com.ExecuteNonQuery()

    conn.Close()

    End If

    BindData

    Me.Response.Redirect(Me.Request.Url.PathAndQuery)

    End Sub

     

    Function CreateConnection() As OleDbConnection

    Dim conn As OleDbConnection = New OleDbConnection

    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""d:/web/localuser/mydomain.dk/database/mybase.mdb"";"

    conn.Open()

    Return conn

    End Function

    </script>
     
    Hope this can help u.
  •  01-17-2007, 6:10 PM 25892 in reply to 25865

    Re: ....mdb" is not a valid virtual path. but it's is there.

    hope that the code can help.
View as RSS news feed in XML