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,028

HOME > .NET Framework > Forum > vb.net ทำไมมันบันทึกไม่ได้ค่ะ ติดตรงไหนรึเปล่าช่วยดูให้หน่อยนะคะ



 

vb.net ทำไมมันบันทึกไม่ได้ค่ะ ติดตรงไหนรึเปล่าช่วยดูให้หน่อยนะคะ

 



Topic : 090898

Guest




Code (VB.NET)
Imports System.Data.SqlClient
Public Class frmCusShare
    Dim conn As SqlConnection
    Dim com As SqlCommand
    Dim ap As SqlDataAdapter
    Dim ds As New DataSet()
    Dim dt As New DataTable
    Dim dr As SqlDataReader
    Dim numm As Integer = 0
    Dim n As Integer = 0
    Private Sub frmCusShare_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conn = New SqlConnection()
        With conn
            If .State = ConnectionState.Open Then .Close()
            .ConnectionString = Database.strConn.ToString
            .Open()
        End With
        Number()
        ShowData()
        TextBox9.Text = frmLogin.b.ToString()
    End Sub
    Private Sub ShowData()
        With conn
            If .State = ConnectionState.Open Then .Close()
            .Open()
        End With
        ds.Clear()
        Dim sql As String = "Select รหัสการถอนหุ้น,รหัสสมาชิก,ชื่อสมาชิก,จำนวนหุ้นที่ถอน,มูลค่าในการถอนหุ้น From ถอนหุ้น Where สถานะ=1 Order by รหัสการถอนหุ้น"
        com = New SqlCommand(sql, conn)
        ap = New SqlDataAdapter(com)
        ap.Fill(ds, "ถอนหุ้น")
        DataGridView1.DataSource = ds.Tables("ถอนหุ้น")
        DataGridView1.Columns.Item(0).Width = 120
        DataGridView1.Columns.Item(1).Width = 110
        DataGridView1.Columns.Item(2).Width = 200
        DataGridView1.Columns.Item(3).Width = 130
        DataGridView1.Columns.Item(4).Width = 138
        conn.Close()
    End Sub
    Private Sub Number()
        With conn
            If .State = ConnectionState.Open Then .Close()
            .Open()
        End With
        dt.Clear()
        Dim sql2 As String = "SELECT รหัสการถอนหุ้น FROM ถอนหุ้น"
        com = New SqlCommand()
        With com
            .CommandType = CommandType.Text
            .CommandText = sql2
            .Connection = conn
            .Parameters.Clear()
            .Parameters.Add("รหัสการถอนหุ้น", SqlDbType.VarChar).Value = "001"
            dr = .ExecuteReader()
            If dr.HasRows Then
                dt = New DataTable
                dt.Load(dr)
                numm = (CInt(dt.Rows(dt.Rows.Count - 1).Item("รหัสการถอนหุ้น").ToString)) + 1
                dt.Clear()
                dr.Close()
                conn.Close()
                If (numm < 10) Then
                    TextBox10.Text = "00" & numm
                Else
                    TextBox10.Text = "0" & numm
                End If
            Else
                conn.Close()
                TextBox10.Text = "001"
            End If
        End With
    End Sub
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        conn.Open()
        Dim sql As String = "UPDATE ถอนหุ้น SET สถานะ=2 Where สถานะ=1"
        com = New SqlCommand(sql, conn)
        com.ExecuteNonQuery()
        conn.Close()
        frmMain.Show()
        Me.Close()
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        With conn
            If .State = ConnectionState.Open Then .Close()
            .Open()
        End With
        Try
            Dim ac As String = "SELECT * FROM member where m_id='" & TextBox1.Text.Trim & "'"
            com = New SqlCommand
            With com
                .CommandType = CommandType.Text
                .CommandText = ac
                .Connection = conn
                .Parameters.Clear()
                .Parameters.Add("member", SqlDbType.VarChar).Value = TextBox1.Text.Trim
                dr = .ExecuteReader()
                If dr.HasRows Then
                    dt = New DataTable
                    dt.Load(dr)
                    TextBox2.Text = dt.Rows(0).Item("m_name").ToString
                    TextBox3.Text = dt.Rows(0).Item("m_nhun").ToString
                    n = CInt(dt.Rows(0).Item("m_phun").ToString)
                    TextBox4.Text = dt.Rows(0).Item("m_thun").ToString
                    dr.Close()
                    conn.Close()
                Else

                End If
            End With
        Catch ex As Exception

        End Try
    End Sub

    Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged
        Try
            Dim i As Integer = CInt(TextBox5.Text.Trim)
            If (i > CInt(TextBox3.Text.Trim)) Then
                MessageBox.Show("ถอนหุ้นเกินจำนวน", "การตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Stop)
                TextBox5.Text = ""
            Else
                TextBox6.Text = CInt(TextBox3.Text.Trim) - i
                TextBox7.Text = i * n
                TextBox8.Text = CInt(TextBox4.Text.Trim) - CInt(TextBox7.Text.Trim)
            End If

        Catch ex As Exception
            TextBox5.Text = ""
        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        With conn
            If .State = ConnectionState.Open Then .Close()
            .Open()
        End With
        Try

            If TextBox1.Text = "" Or TextBox5.Text = "" Then
                MessageBox.Show("กรุณากรอกข้อมูลให้ครบทุกช่องด้วยค่ะ", "การตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Else
                Dim SQL1 As String = "INSERT INTO ถอนหุ้น(รหัสการถอนหุ้น,รหัสสมาชิก,ชื่อสมาชิก,จำนวนหุ้นที่ถอน,มูลค่าในการถอนหุ้น,วันที่ถอนหุ้น,ชื่อพนักงาน,สถานะ) VALUES('" & TextBox10.Text & "','" & TextBox1.Text & "','" & TextBox2.Text & "','" & CInt(TextBox5.Text) & "','" & CInt(TextBox7.Text) & "','" & DateValue(DateTimePicker1.Value) & "','" & TextBox9.Text & "',1)"
                com = New SqlCommand(SQL1, conn)
                com.ExecuteNonQuery()
                conn.Close()
                conn.Open()
                Dim sql As String = "UPDATE member SET m_nhun='" & TextBox6.Text.Trim & "',m_thun='" & TextBox8.Text.Trim & "'  Where m_id='" & TextBox1.Text.Trim & "'"
                com = New SqlCommand(sql, conn)
                com.ExecuteNonQuery()
                conn.Close()
                Clear()
                ShowData()
            End If
        Catch ex As Exception

        End Try
    End Sub
    Private Sub Clear()
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()
        TextBox6.Clear()
        TextBox7.Clear()
        TextBox8.Clear()
        Number()
        TextBox1.Focus()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Clear()
    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

    End Sub
End Class




Tag : .NET, Ms SQL Server 2008







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-02-15 02:50:15 By : Aonaka View : 701 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

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

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

มี Error ไหม๊ครับ ว่าแต่ฟิวด์ควรเปลี่ยนเป็นภาษาอังกฤษน่ะครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-15 06:41:38 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : vb.net ทำไมมันบันทึกไม่ได้ค่ะ ติดตรงไหนรึเปล่าช่วยดูให้หน่อยนะคะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

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