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 > ขอคำแนะนำ เกี่ยวกับ select data from database แล้วนำมา compare กับ text box ที่ input เข้าไป



 

ขอคำแนะนำ เกี่ยวกับ select data from database แล้วนำมา compare กับ text box ที่ input เข้าไป

 



Topic : 039634



โพสกระทู้ ( 2 )
บทความ ( 0 )



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




ขอคำแนะนำ เกี่ยวกับ 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()

Source File: Q:\POShipment_ann\Trans.aspx.vb Line: 35


Code:

Option Explicit On
Option Strict On

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

dr1.Read()
t_qty = CInt(dr1.GetDecimal(0))
dr1.Close()

Conn1.Close()

If qty_input <= t_qty Then

' ====== Open database ShopFloor ======
Dim strConn As String
strConn = "Data Source=THBKKAP01;Initial Catalog=ShopFloorControl;Persist Security Info=True;User ID=MFTUser;Password=mftuser;"

Dim Conn As New SqlConnection(strConn)
Conn.Open()

' ====== Set Max ID ======
Dim sqlSel As String
sqlSel = "SELECT max(tran_id) as max_tran_id FROM tbl_po_shipment"

Dim sel_id As New SqlCommand(sqlSel, Conn)
Dim dr As SqlDataReader = sel_id.ExecuteReader
dr.Read()

Dim max_id As Integer
max_id = CInt(dr.GetDecimal(0))
max_id = max_id + 1
'max_id = 1
dr.Close()
' ====================

' ====== Insert Main transaction ======
Dim sqlAdd As String
sqlAdd = "INSERT INTO tbl_po_shipment (tran_id, pallet, po, invoice, quantity, status, create_datetime,update_datetime) "
sqlAdd &= " VALUES (" & max_id & ","
'sqlAdd &= "'" & t_do.Text & "'," Remove by Ann not key in DO
sqlAdd &= "'" & t_pallet.Text & "',"
sqlAdd &= "'" & po & "',"
sqlAdd &= "'',"
sqlAdd &= "" & t_quantity.Text & ","
sqlAdd &= "" & 1 & "," 'Added by May on 17/7/2007 17:25 : Delete Record
sqlAdd &= "'" & current_date & "',"
'sqlAdd &= "'" & t_orno.SelectedValue & "'," Remove by Ann not key in Sales Order
sqlAdd &= "'" & current_date & "')"

Dim com As New SqlCommand(sqlAdd, Conn)
com.ExecuteNonQuery()

' =====================================

Conn.Close()
Else
Label1.Text = ("Input over")
End If


'Response.Redirect("Trans.aspx?main_tran_id=" & main_tran_id & "&proc_code=" & proc_code & "")
Response.Redirect("Trans.aspx")
End Sub

End Class





Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-02-26 16:02:49 By : annlpg View : 1432 Reply : 1
 

 

No. 1



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

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

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

sqlQty = "select a.t_qntl from ttisfc001800 a"
sqlQty &= "where a.t_pdno = " & po

ข้างหลัง a น่าจะวรรคซะ 1 น่ะครับ เพราะเวลต่อ string มันจะได้เป็น

Code
select a.t_qntl from ttisfc001800 awhere a.t_pdno







Date : 2010-02-27 08:24:29 By : webmaster
 

   

ค้นหาข้อมูล


   
 

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