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

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



 

ช่วยดูให้หน่อยค่ะ พอดีบันทึกข้อมูลหน้าการเพิ่มหุ้นไม่ได้ค่ะ อยากรู้ว่าต้องใช้คำสั่งไหนเพิ่มอีกมั้ยคะ

 



Topic : 090586

Guest




Code (VB.NET)
Imports System.Data.SqlClient

Public Class frmAddShare
    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 Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
       
        conn.Close()
        frmMain.Show()
        Me.Close()
    End Sub

    Private Sub frmAddShare_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 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)
            TextBox6.Text = i + CInt(TextBox3.Text.Trim)
            TextBox7.Text = i * n
            TextBox8.Text = CInt(TextBox4.Text.Trim) + CInt(TextBox7.Text.Trim)
        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) & "','" & DateTimePicker1.Text & "','" & 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_phun ='" & 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 TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

    End Sub
End Class




Tag : .NET, Ms SQL Server 2008







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-02-09 04:37:06 By : Aonaka View : 651 Reply : 2
 

 

No. 1

Guest


มันไม่มีการฟ้อง error ด้วยค่ะ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-09 04:37:29 By : Aonaka
 


 

No. 2



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

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

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

ใช้การ Debug ดูครับ คาดว่ามันไม่เข้าเงื่อนไขที่จะ Update หรือ Insert ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-09 07:41:39 By : mr.win
 

   

ค้นหาข้อมูล


   
 

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