Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim comadd As OleDbCommand = New OleDbCommand
Dim num0 As String = 0
setcombovalue()
Dim NamePic As String = Now.Date.ToString("ddMMyy") & Now.TimeOfDay.Hours.ToString("00") & Now.TimeOfDay.Minutes.ToString("00") & ".jpg"
Dim Openfile As String = OpenFileDialog1.FileName
If BtStatus = "Add" Then
sqlconn = "INSERT into tblmember(mem_id,mem_name,mem_add,mem_sex,mem_tel,mem_email,mem_con,mem_pic) VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox6.Text & "','" & tmpFileName & "')"
With comadd
.CommandType = CommandType.Text
.CommandText = sqlconn
.Connection = Conn
.ExecuteNonQuery()
End With
sqlconn1 = "INSERT into sharesale(mem_id,share_amount,share_price,share_date,share_emp,share_sta) VALUES(" & TextBox1.Text & ", 0,0,ลงทะเบียนใหม่,'" & TextBox7.Text & "',ลงทะเบียนใหม่)"
With comadd
.CommandType = CommandType.Text
.CommandText = sqlconn1
.Connection = Conn
.ExecuteNonQuery()
End With 'ส่วนนี้เป็นส่วน ตาราง 2คับ error ตามด้านบน
ElseIf BtStatus = "Edit" Then
If tmpFileName <> "" Then
sqlconn = " UPDATE tblmember SET mem_name='" & TextBox2.Text & "',mem_add='" &TextBox3.Text& "',mem_sex='" & TextBox4.Text & "',mem_tel='" & TextBox5.Text & "',mem_email='" & TextBox6.Text & "',mem_con='" & datemem & "',share_total='" & Nothing & "',mem_pic='" & tmpFileName & "' WHERE mem_id = '" & TextBox1.Text & "'"
Else
sqlconn = " UPDATE tblmember SET mem_name='" & TextBox2.Text & "',mem_add='" & TextBox3.Text & "',mem_sex='" & TextBox4.Text & "',mem_tel='" & TextBox5.Text & "',mem_email='" & TextBox6.Text & "',mem_con='" & datemem & "',share_total='" & Nothing & "' WHERE mem_id = '" & TextBox1.Text & "'"
End If
With comadd
.CommandType = CommandType.Text
.CommandText = sqlconn
.Connection = Conn
.ExecuteNonQuery()
End With
End sub
Imports System.Data
Imports System.Data.OleDb
Public Class Form2
Dim Conn As New OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
Dim dr As DataRow
Dim IsFind As Boolean = False
Dim sqlconn As String = ""
Dim sqlconn1 As String = ""
Dim BtStatus As String
Dim PicSelect As String
Dim datemem As String
Dim tmpFileName As String = ""