 |
|
บันทึกข้อมูลไม่ได้ VB2008 รบกวนช่วยดูให้หน่อยนะคับ Number of query values and destination fields are not the same |
|
 |
|
|
 |
 |
|
รับกวนหน่อยคับ ติด เวลาบันทึกมันขึ้น

รบกวนด้วยนะคับงานจะส่งแล้ว
Code (VB.NET)
Imports System.Data.OleDb
Imports System.Data
Public Class Form2
Public conn As New OleDbConnection
Public Sub connectData() Handles MyBase.Load
Dim P As String
'TODO: This line of code loads data into the 'DataSet.Age' table. You can move, or remove it, as needed.
Me.AgeTableAdapter.Fill(Me.DataSet.Age)
'TODO: This line of code loads data into the 'DataSet.Sex' table. You can move, or remove it, as needed.
Me.SexTableAdapter.Fill(Me.DataSet.Sex)
'TODO: This line of code loads data into the 'DataSet.AddP' table. You can move, or remove it, as needed.
Me.AddPTableAdapter.Fill(Me.DataSet.AddP)
'TODO: This line of code loads data into the 'DataSet.Product' table. You can move, or remove it, as needed.
Me.ProductTableAdapter.Fill(Me.DataSet.Product)
If conn.State = ConnectionState.Open Then conn.Close()
P = "Provider=Microsoft.Jet.OLEDB.4.0;"
P = P + "Data Source=d:\TPro\data.mdb;"
P += "User Id=admin;Password=;"
conn.ConnectionString = P
conn.Open()
End Sub
Public Function ExecuteSQL(ByVal prmSQL As String) As Boolean
connectData()
Dim addCom As New OleDbCommand
With addCom
.CommandType = CommandType.Text
.CommandText = prmSQL
.Connection = conn
.ExecuteNonQuery()
End With
ExecuteSQL = True
End Function
Private Sub Formload() Handles MyBase.Load
connectData()
End Sub
Private Sub AddData() Handles btnAdd.Click
Dim S As String
S = "INSERT INTO Addp (Code,Pname,Sex,Age,[Price])VALUES("
S += "'" & txtcode.Text & "',"
S += "'" & cmbName.Text & "'"
S += "'" & cmbSex.Text & "'"
S += "'" & cmbAge.Text & "'"
S += "'" & txtPrice.Text & "'"
S += ")"
ExecuteSQL(S)
MessageBox.Show("บันทึกเรียบร้อย", "ยืนยัน")
End Sub
Tag : VS 2008 (.NET 3.x)
|
|
 |
 |
 |
 |
Date :
2012-05-19 09:24:00 |
By :
suthanachan1 |
View :
1498 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Debug ค่า prmSQL ออกมาดูครับ พวก Column กับ value ครับ
|
 |
 |
 |
 |
Date :
2012-05-19 09:26:38 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พึ่งให้เขียนอะคับ
Debug ค่า prmSQL ออกมาดูครับ พวก Column กับ value ครับ
นี้ทำยังไงครับ
งงอ่ะคับ
|
ประวัติการแก้ไข 2012-05-19 09:53:19
 |
 |
 |
 |
Date :
2012-05-19 09:48:49 |
By :
suthanachan1 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หรือ
เป็นที่ ใช้ combobox

data.mdb คับ

งงมากคับรบกวนหน่อยคับ
|
 |
 |
 |
 |
Date :
2012-05-19 10:11:42 |
By :
suthanachan1 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมให้คุณ Debug SQL ออกมาดูครับ
|
 |
 |
 |
 |
Date :
2012-05-19 10:16:25 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันขึ้นอย่างนี้อะคับ

|
 |
 |
 |
 |
Date :
2012-05-19 10:33:33 |
By :
suthanachan1 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|