ขอคำแนะนำ เกี่ยวกับ select data from database แล้วนำมา compare กับ text box ที่ input เข้าไป เพื่อจะเปรียบเทียบว่า Qty ที่ input เข้ามา ไม่ให้เกิน Order Qty. แต่ว่ามี error:
error: Line 1: Incorrect syntax near 'a'.
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.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'a'.
Source Error:
Line 33: Dim t_qty As Integer
Line 34: Dim cmd As New SqlCommand(sqlQty, Conn1)
Line 35: Dim dr1 As SqlDataReader = cmd.ExecuteReader
Line 36:
Line 37: dr1.Read()
Imports System.Data
Imports System.Data.SqlClient
Partial Class Trans
Inherits System.Web.UI.Page
Protected Sub save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles save.Click
' ====== Set Parameter Value ======
Dim current_date As Date
current_date = Date.Now
Dim po As String
po = t_po.SelectedValue
Dim qty_input As Integer
qty_input = CInt(t_quantity.Text)
' =================================
Dim strConn1 As String
Dim sqlQty As String
strConn1 = "Data Source=THBKKAP01;Initial Catalog=erplndb;Persist Security Info=True;User ID=MFTUser;Password=mftuser;"
Dim Conn1 As New SqlConnection(strConn1)
Conn1.Open()
' ####### Select Data #######
sqlQty = "select a.t_qntl from ttisfc001800 a"
sqlQty &= "where a.t_pdno = " & po
Dim t_qty As Integer
Dim cmd As New SqlCommand(sqlQty, Conn1)
Dim dr1 As SqlDataReader = cmd.ExecuteReader