Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > .NET Framework > Forum > พี่ๆๆค่ะมาอีกแร้วค่ะ erorr ช่วยดูให้หน่อยค่ะ แก้จนมึนแล้วอ่า


 

[.NET] พี่ๆๆค่ะมาอีกแร้วค่ะ erorr ช่วยดูให้หน่อยค่ะ แก้จนมึนแล้วอ่า

 
Topic : 039046



โพสกระทู้ ( 60 )
บทความ ( 0 )



สถานะออฟไลน์



ช่วยดูให้หน่อยค่ะโค้ดอันนี้มันerorrแก้ไขไม่ได้อ่ะ ขอบคุณล่วงหน้านะค่ะCode (VB.NET)
01.Imports System.Data
02.Imports System.Data.OleDb
03.Partial Class frm_edit2
04.    Inherits System.Web.UI.Page
05.    Dim objConn As New OleDbConnection
06.    Dim objCmd As New OleDbCommand
07.    Dim dtReader As OleDbDataReader
08.    Dim strConnString, strSQL As String
09. 
10.    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
11.        strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data/mydatabase.mdb") & ";Jet OLEDB:Database Password=;"
12.        objConn.ConnectionString = strConnString
13.        objConn.Open()
14. 
15.        If Not Page.IsPostBack() Then
16.            ViewData()
17.        End If
18. 
19.        Dim dtAdapter As OleDbDataAdapter
20.        Dim dt As New DataTable
21.        If Not Page.IsPostBack() Then
22. 
23.            Dim strSQL As String
24.            strSQL = "SELECT *FROM tb_type"
25.            dtAdapter = New OleDbDataAdapter(strSQL, objConn)
26.            dtAdapter.Fill(dt)
27.            dtAdapter = Nothing
28.            objConn.Close()
29.            objConn = Nothing
30.            With Me.listtype_id
31.                .DataSource = dt
32.                .DataTextField = "type_name"
33.                .DataValueField = "type_id"
34.                .DataBind()
35. 
36.            End With
37.            listtype_id.SelectedIndex = listtype_id.Items.IndexOf(listtype_id.Items.FindByValue("type_id"))
38.        End If
39.    End Sub
40. 
41.    Sub ViewData()
42.        '*** DataTable ***'
43.        Dim dtAdapter As OleDbDataAdapter
44.        Dim dt As New DataTable
45.        strSQL = "SELECT * FROM tb_book WHERE book_id = '" & Request.QueryString("book_id") & "' "
46.        dtAdapter = New OleDbDataAdapter(strSQL, objConn)
47.        dtAdapter.Fill(dt)
48. 
49.        If dt.Rows.Count > 0 Then
50.            Me.txtbook_id.Text = dt.Rows(0)("book_id")
51.            Me.txtbook_name.Text = dt.Rows(0)("book_name")
52.            Me.txtbook_by.Text = dt.Rows(0)("book_by")
53.            Me.txtbook_number.Text = dt.Rows(0)("book_number")
54.            Me.txtbook_detail.Text = dt.Rows(0)("book_detail")
55.            Me.txtbook_price.Text = dt.Rows(0)("book_price")
56.            Me.listtype_id.SelectedItem.Value = dt.Rows(0)("type_id")
57.        End If
58.    End Sub
59. 
60.    Protected Sub save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles save.Click
61.        strSQL = "UPDATE tb_book SET " & _
62.       " book_id = '" & Me.txtbook_id.Text & "' " & _
63.       " ,book_name = '" & Me.txtbook_name.Text & "' " & _
64.       " ,book_by = '" & Me.txtbook_by.Text & "' " & _
65.       " ,book_number = '" & Me.txtbook_number.Text & "' " & _
66.       " ,book_detail = '" & Me.txtbook_detail.Text & "' " & _
67.       " ,book_price = '" & Me.txtbook_price.Text & "' " & _
68.       " ,type_id = '" & Me.listtype_id.SelectedItem.Value & "' " & _
69.       " WHERE book_id = '" & Request.QueryString("book_id") & "' "
70. 
71.        objCmd = New OleDbCommand
72.        With objCmd
73.            .Connection = objConn
74.            .CommandText = strSQL
75.            .CommandType = CommandType.Text
76.        End With
77. 
78.        Me.pnlAdd.Visible = False
79.        Try
80.            objCmd.ExecuteNonQuery()
81.            Me.lblstatus.Text = "แก้ไขข้อมูลเรียบร้อยแล้ว"
82.            Me.lblstatus.Visible = True
83.        Catch ex As Exception
84.            Me.lblstatus.Text = "ไม่สามารถแก้ไขข้อมูลได้"
85.        End Try
86. 
87.    End Sub
88. 
89.    Sub Page_UnLoad()
90.        objConn.Close()
91.        objConn = Nothing
92.    End Sub
93.End Class

มัน ขึ้นเแบบนี้ค่ะ
Server Error in '/Project' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
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 reference not set to an instance of an object.

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:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

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.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
frm_edit2.ViewData() +556
frm_edit2.Page_Load(Object sender, EventArgs e) +128
System.Web.UI.Control.OnLoad(EventArgs e) +73
System.Web.UI.Control.LoadRecursive() +52
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2184




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927



Tag : - - - -

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-02-16 13:34:54 By : neenarat View : 2479 Reply : 3
 

 

No. 1



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


ทำตามมันหน่อย ไปแก้ web.config เพิ่มส่วนนี้ก่อน

Code
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>


ส่วน System.NullReferenceException ไปอ้งอิง object ที่เป้น null เข้าให้แล้ว
Date : 2010-02-16 14:01:21 By : tungman
 

 

No. 2



โพสกระทู้ ( 60 )
บทความ ( 0 )



สถานะออฟไลน์


งืมจะลองทำดูค่ะแต่ก็ยังงงงอ่า
เด่วไปส่งโปรเจ็กก่อนแล้วกันค่ะเด่วจะมางงใหม่
ขอบคุณมากๆๆค่ะ
Date : 2010-02-16 15:15:00 By : neenarat
 

 

No. 3



โพสกระทู้ ( 60 )
บทความ ( 0 )



สถานะออฟไลน์


สอบเสร็จแล้วมาทำต่อไม่ได้อ่า
Date : 2010-02-28 02:28:50 By : neenarat
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : พี่ๆๆค่ะมาอีกแร้วค่ะ erorr ช่วยดูให้หน่อยค่ะ แก้จนมึนแล้วอ่า
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่