Kan godt køre på egen pc med VS2005 men ikke ved min host
HejHvis jeg har denne kode conn så køre det fint på min egen pc med win xp pro samt vs 2005
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Context.Server.MapPath("../App_data/mybase.mdb") + ";"
Men retter jeg det til dette
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Context.Server.MapPath("d:/web/localuser/domain.dk/database/mybase.mdb") + ";"
Så får jeg denne fejl
Detaljer om undtagelse: System.Web.HttpException: 'd:/web/localuser/domain.dk/database/mybase.mdb' er ikke en gyldig virtuel sti.
Kildefejl:
Linje 120: Function CreateConnection() As OleDbConnection
Linje 121: Dim conn As OleDbConnection = New OleDbConnection
Linje 122: conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Context.Server.MapPath("d:/web/localuser/domain.dk/database/mybase.mdb") + ";"
Linje 123: conn.Open()
Linje 124: Return conn
det samme gælder hvis jeg ændre / til \.
Håber nogle kan hjælpe min kode er:
<%@ Page Language="vb" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ 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 id="Form1" runat="server">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="760">
<br><br>
<asp:Datagrid runat="server"
Id="MyDataGrid"
cellpadding="3"
cellspacing="0"
Headerstyle-BackColor="#eeeeee"
Headerstyle-Font-Bold="True"
BackColor="#f5f5f5"
BorderWidth="1"
Width="720px"
Font-Name="Arial"
Font-Size="12px"
BorderColor="#999999"
AutogenerateColumns="False"
OnItemCommand="UpdateItem"
>
<Columns>
<asp:BoundColumn DataField="SiteMainID" Visible="False" />
<asp:BoundColumn ItemStyle-Width="50px" DataField="SiteMainID" HeaderText="ID" />
<asp:BoundColumn ItemStyle-Width="430px" DataField="SiteMainIdentity" HeaderText="Identity" />
<asp:BoundColumn ItemStyle-Width="120px" DataField="SiteMainText" HeaderText="Text" />
<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="400px" 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 MainText"
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 MainText 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 MainText 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 MainText 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 MainText (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=" + Context.Server.MapPath("d:\web\localuser\domain.dk\database\mybase.mdb") + ";"
conn.Open()
Return conn
End Function
</script>