10. februar 2004 - 19:03Der er
10 kommentarer og 1 løsning
Jeg kan ikke hente data fra Access
Hejsa Eksperter
Jeg er en ASP.NET nybegynder og har en lille problem her...jeg ved ikke hvad der er galt, men denne kode skulle virke men det gøre den så bare ik' desværre...så hvad er der galt eksperter?
sub Page_Load dim conn,sql,comm,read conn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & server.mappath("news.mdb")) conn.Open()
sql="SELECT * FROM allnews" comm=New OleDbCommand(sql,conn) read=comm.ExecuteReader() News.DataSource=read News.DataBind()
Object variable or With block variable not set. 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.NullReferenceException: Object variable or With block variable not set.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
OK...tak jaffafo nu er problemet løst men har faaet en anden Hvad er der galt med denne kode?
<script runat="server">
Dim id As String
sub Page_Load dim conn,sql,comm,read,sql2,comm2,read2 conn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & server.mappath("news.mdb")) conn.Open()
sql="SELECT * FROM allnews" id = Request.QueryString("id") sql2="SELECT * FROM allnews WHERE id=" & id
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.