 |
|
Erorr No value given for one or more required parameters. ค่ะรบกวนช่วยพี่ๆดูให้หน่อยค่ะ |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub frmListAllProducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Windows.Forms.Cursor.Current = Cursors.WaitCursor
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
Dim sqlBook As String = ""
sqlBook = "SELECT t_Product.Product_id, t_Product.Product_name, t_Product.Product_Brand,"
sqlBook &= " t_Product.Product_Price, t_Product.Product_Detail, t_Product.Product_Total"
sqlBook &= " FROM t_Product"
'sqlBook &= " WHERE(Book.BookTypeCode = BookType.BookTypeCode)"
'sqlBook &= " AND (Book.BookStatus='1')"
If IsFind = True Then
ds.Tables("t_Product").Clear()
End If
da = New OleDbDataAdapter(sqlBook, Conn)
da.Fill(ds, "t_Product") ' erorr บรรทัดนี้นะค่ะ
If ds.Tables("t_Product").Rows.Count <> 0 Then
IsFind = True
With grdProducts
.AllowNavigation = False
.ReadOnly = True
.DataSource = ds.Tables("t_Product")
End With
Else
IsFind = False
grdProducts.DataSource = Nothing
End If
FormatDataGridWithData()
Windows.Forms.Cursor.Current = Cursors.Default
End Sub
Tag : .NET, Ms Access, VB.NET
|
|
 |
 |
 |
 |
Date :
2012-03-15 23:07:35 |
By :
bow |
View :
1199 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จากประสบการณ์ตรงของผม คำสั่ง SQL ผิดแน่นอนครับ
ลองใช้แบบนี้ซิครับ พิมพ์แต่ชื่อฟิลด์เลย เช่น
SELECT Product_ID,Product_Name FROM t_Product
แบบนี้ ไม่น่าจะ Error
แต่ที่ผมดูแล้วนะ ผมขอเดาวา คุณอาจจะพิมพ์ชื่อฟิลด์ไม่ตรง น่าจะเป็นแบบนี้ 99% เลยล่ะ
|
 |
 |
 |
 |
Date :
2012-03-16 10:42:37 |
By :
tonyjame |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช่ครับ Query น่าจะผิดแน่นอน
|
 |
 |
 |
 |
Date :
2012-03-16 11:23:08 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ไขแล้ว ยัเป็นเหมือนเดิมเลยค่ะ รบกวนพี่ช่วยหน่อยนะค่ะ
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.OleDb
Public Class frmListAllProducts
Inherits System.Windows.Forms.Form
Const DATABASE_FILE As String = "C:\\Database\\Pharmacy.mdb"
Dim strConnection As String = " Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & DATABASE_FILE
Dim Conn As New OleDbConnection(strConnection)
'Dim Conn As OleDbConnection = New OleDbConnection()
Dim da As OleDbDataAdapter
Dim ds As DataSet = New DataSet
Dim IsFind As Boolean = False
Dim ToClose As Boolean = False
Private Sub frmListAllProducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Windows.Forms.Cursor.Current = Cursors.WaitCursor
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
Dim sqlProduct As String = ""
sqlProduct = "SELECT Product_id, Product_name, Product_Brand,"
sqlProduct &= " Product_Detail, Product_Price, Product_Total"
sqlProduct &= " FROM t_Products"
If IsFind = True Then
ds.Tables("t_Products").Clear()
End If
da = New OleDbDataAdapter(sqlProduct, Conn)
da.SelectCommand.CommandText = sqlProduct
da.Fill(ds, "t_Products")
If ds.Tables("t_Products").Rows.Count <> 0 Then
IsFind = True
With grdProducts
.AllowNavigation = False
.ReadOnly = True
.DataSource = ds.Tables("t_Products")
End With
Else
IsFind = False
grdProducts.DataSource = Nothing
End If
FormatDataGridWithData()
Windows.Forms.Cursor.Current = Cursors.Default
End Sub
|
 |
 |
 |
 |
Date :
2012-03-16 22:43:12 |
By :
Bow |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเปลี่ยนเป็น sqlProduct =" SELECT * FROM t_Products " ซิครับว่าได้หรือไม่
|
 |
 |
 |
 |
Date :
2012-03-17 15:01:22 |
By :
ผ่านมาดูครับ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|