 |
|
รบกวนช่วยดูหน่อยครับ ติดปัญหา VB 2008 เขียนข้อมูลไม่ลง Access 2003 ครับ รายละเอียดข้างใน |
|
 |
|
|
 |
 |
|
คือผมติดปัญหาการนำข้อมูลจากแบบสอบถาม ลง db access 2003 ครับรายละเอียดดังนี้ครับ
Code (VB.NET)
Imports System.Data.OleDb
Public Class frmadd
Dim conn As New OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
Dim strcon As String
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Documents\account.mdb"
With conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strcon
.Open()
End With
Dim sqlaccount As String
Dim cmdaccount As New OleDbCommand
sqlaccount = "INSERT INTO account (no, ac_name, ac_id, range, ac_begin, ac_finish, ac_fund, ac_tax) VALUES (2, 'ทดสอบ2', '6666', 12, '1/1/2010', '1/1/2011', 20000, 6)"
MessageBox.Show(sqlaccount)
Try
With cmdaccount
.CommandType = CommandType.Text
.CommandText = sqlaccount
.Connection = conn
.ExecuteNonQuery()
End With
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
database คือ
no = number
ac_name = text
ac_id = text
range = number
ac_begin = date
ac_finish = date
ac_fund = currency
ac_tax = number
error ที่มันรายงานตามภาพครับ

ข้อมูลเพิ่มเติม
Windows 7 64bit
VB 2008 fix Parameter X86
Access 2003
ขอบคุณล่วงหน้าครับ
Tag : .NET, Ms Access, VS 2008 (.NET 3.x)
|
|
 |
 |
 |
 |
Date :
2011-01-11 12:22:26 |
By :
DemonXIII |
View :
1369 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
"INSERT INTO account (no, ac_name, ac_id, range, ac_begin, ac_finish, ac_fund, ac_tax) VALUES (2, 'ทดสอบ2', '6666', 12, #1/1/2010#, #1/1/2011#, 20000, 6)"
|
 |
 |
 |
 |
Date :
2011-01-11 13:05:32 |
By :
kaimuk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคูณมากครับ ได้ผลยังไงจะมากบอกครับ
EDIT : หลังจากลองทำแล้ว ต้องเพิ่มลักษณะวันที่ โดยมี # เข้าด้วยครับ ไม่งั้น แม้ไม่ Error แต่ผลไม่เข้า
ขอบคุณมากๆครับ
|
ประวัติการแก้ไข 2011-01-11 13:55:28
 |
 |
 |
 |
Date :
2011-01-11 13:49:59 |
By :
DemonXIII |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอถามเพิ่มเติมครับ
มันบันทึกใน db แต่ ไฟล์ db นั้น มันอยู่ใน ตัว Folder Project
ตอนรันก็ไม่มี error แต่ไฟล์ที่ทำการ connect ไว้ไม่มีการเปลี่ยนแปลงครับ
มันเกิดจาก ?
ป.ล. แต่ไฟล์ใน Debug มีการเปลี่ยนแปลงครับ
งง มากมาย
|
 |
 |
 |
 |
Date :
2011-01-11 14:29:00 |
By :
DemonXIII |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|