Private Sub Showid()
Dim conStr As String = "Data Source=MANUJOGA-NB\SQLEXPRESS;Initial Catalog=CarCare;Integrated Security=True"
Dim Connection As New SqlConnection(conStr)
Dim Dss As Integer = 0
Connection.Open()
Dim sql As String = "SELECT max(Cus_id)+1 as Cus_id FROM Customer"
Dim command As New SqlCommand(sql, Connection)
Dim reader As SqlDataReader = command.ExecuteReader()
While reader.Read()
ListBox1.Items.Add(reader("Cus_id")) <<----- ตรงนี้ครับที่มันโชว์ได้
idCusTextbox.text <<----- อยากให้มันโชว์ในส่วนนี้ครับ
End While
Connection.Close()
End Sub
ขอบพระคุณทุกท่านมากนะครับ
Private Sub Showid()
Dim conStr As String = "Data Source=MANUJOGA-NB\SQLEXPRESS;Initial Catalog=CarCare;Integrated Security=True"
Dim Connection As New SqlConnection(conStr)
Dim Dss As Integer = 0
Connection.Open()
Dim sql As String = "SELECT max(Cus_id)+1 as Cus_id FROM Customer"
Dim command As New SqlCommand(sql, Connection)
Dim reader As SqlDataReader = command.ExecuteReader()
Dim strCusID As String
While reader.Read()
strCusID = reader("Cus_id"
ListBox1.Items.Add(strCusID) <<----- ตรงนี้ครับที่มันโชว์ได้
idCusTextbox.text = strCusID <<----- อยากให้มันโชว์ในส่วนนี้ครับ
End While
Connection.Close()
End Sub
Private Sub Showid()
Dim conStr As String = "Data Source=MANUJOGA-NB\SQLEXPRESS;Initial Catalog=CarCare;Integrated Security=True"
Dim Connection As New SqlConnection(conStr)
Dim Dss As Integer = 0
Connection.Open()
Dim sql As String = "SELECT max(Cus_id)+1 as Cus_id FROM Customer"
Dim command As New SqlCommand(sql, Connection)
Dim reader As SqlDataReader = command.ExecuteReader()
Dim strCusID As String
While reader.Read()
strCusID = reader("Cus_id" <<<< มัน Error ตรงนี้ครับพี่
ListBox1.Items.Add(strCusID)
idCusTextBox.Text = strCusID
End While
Connection.Close()
End Sub
Private Sub Showid()
Dim conStr As String = "Data Source=MANUJOGA-NB\SQLEXPRESS;Initial Catalog=CarCare;Integrated Security=True"
Dim Connection As New SqlConnection(conStr)
Dim Dss As Integer = 0
Connection.Open()
Dim sql As String = "SELECT max(Cus_id)+1 as Cus_id FROM Customer"
Dim command As New SqlCommand(sql, Connection)
Dim reader As SqlDataReader = command.ExecuteReader()
Dim strCusID As String
While reader.Read()
strCusID = CStr(reader("Cus_id")) <<< แบบนี้ได้แล้วครับพี่
ListBox1.Items.Add(strCusID)
idCusTextBox.Text = strCusID
End While
Connection.Close()
End Sub