0
SQL文を使ってレコードを正常に取得するには、テキストボックス、ドロップダウンリスト&のラベルを適切なフィールドに正しく割り当てることができますか?私は4つのテーブル&を持っているので、割り当てられたデータはコントロールと一致しません。 (VS2008)私は以下の持っているコントロールにデータを正しく割り当て、SQL Server、VS2008
:
myCmd.CommandText = "SELECT pc.product_category_id, pc.product_category_name, pi.product_image_id, pi.product_image_filename, qr.qrcode_id, qr.qrcode_image_filename, p.product_author FROM Product AS p INNER JOIN ProductCategory AS pc ON p.product_category_id = pc.product_category_id INNER JOIN ProductImage AS pi ON p.product_image_id = pi.product_image_id INNER JOIN QRCode AS qr ON p.qrcode_id = qr.qrcode_id WHERE p.product_id = '" & DropDownList2.Text & "'"
myCmd.Parameters.Add(New SqlParameter("@product_id", (DropDownList2.Text)))
myConn.Open()
'run the query and obtain a reader to get the results
dtrReader = myCmd.ExecuteReader()
'check if there are results
If (dtrReader.Read()) Then
'populate the values of the controls
lblProductID2.Text = dtrReader(0)
txtProductName2.Text = dtrReader(4)
txtProductTitle2.Text = dtrReader(7)
txtProductDescription2.Text = dtrReader(8)
txtProductAuthor2.Text = dtrReader(12)
あなたはSQLインジェクションの脆弱性を持っています。 – SLaks
@SLaks:どこから来ているのか分かります。ありがとうございますが、質問には、フィールドに一致するためのより簡単な方法がありますか? – brainsfrying
既存のコードについて間違っているか不十分ですか? – MatBailie