 |
|
ช่วยชี้แนะเรื่องติดต่อ access 2007 ใน vb 2008 ทีครับ |
|
 |
|
|
 |
 |
|
ช่วยสอนผมทีครับ มือใหม่หัดโพส
ผมไม่เข้าใจว่าจะเขียนโค๊ดในการเรียกฐานข้อมูลaccess2007อย่างไรครับ
คือผมออกเเบบformนี้ในการเพิ่มข้อมูลสมาชิกของระบบครับ
เช่น วันเดือนปี ลงในtextbox รหัสลูกค้า วันเกิดเป็นต้นครับ
เเล้วมีปุ่มbutton ตกลง ในการที่จะsaveข้อมูลลงในฐานข้อมูลaccesss 2007ครับ
โดยมี tool Data GridView ในการโชว์ข้อมูลaccessครับ
นี้เป็นcodeที่เขียนในbutton ตกลงครับ
Code (VB.NET)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("กรุณากรอกข้อมูล วัน/เดือน/ปี ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox1.Focus()
ElseIf TextBox3.Text = "" Then
MsgBox("กรุณากรอก ชื่อ ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox3.Focus()
ElseIf TextBox4.Text = "" Then
MsgBox("กรุณากรอก นามสกุล ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox4.Focus()
ElseIf ComboBox1.Text = "" Then
MsgBox("กรุณากรอก เพศ ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
ComboBox1.Focus()
ElseIf TextBox5.Text = "" Then
MsgBox("กรุณากรอก รหัสประจำตัวประชาชน ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox5.Focus()
ElseIf TextBox6.Text = "" Then
MsgBox("กรุณากรอก วันเกิด ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox6.Focus()
ElseIf TextBox7.Text = "" Then
MsgBox("กรุณากรอก บ้านเลขที่ ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox7.Focus()
ElseIf TextBox8.Text = "" Then
MsgBox("กรุณากรอก แขวง/ตำบล ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox8.Focus()
ElseIf TextBox9.Text = "" Then
MsgBox("กรุณากรอก เขต/อำเภอ ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox9.Focus()
ElseIf TextBox10.Text = "" Then
MsgBox("กรุณากรอก จังหวัด ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox10.Focus()
ElseIf TextBox11.Text = "" Then
MsgBox("กรุณากรอก รหัสไปรษณีย์", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox11.Focus()
ElseIf TextBox12.Text = "" Then
MsgBox("กรุณากรอก เบอร์โทรศัพท์", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox12.Focus()
ElseIf TextBox13.Text = "" Then
MsgBox("กรุณากรอกวันหมดอายุ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox13.Focus()
ElseIf MsgBox("คุณต้องการบันทึกใช่หรือไม่", MsgBoxStyle.Question + MsgBoxStyle.YesNo, " SAVE! ") = MsgBoxResult.Yes Then
End If
End Sub
จะเขียนต่อยังไงครับถ้ามีฐานข้อมูลเเล้วเเต่ผมติดต่อฐานข้อมูลไม่เป็น
ถ้าเข้าใจไม่ผิดเห็นจะต้องเขียนโค๊ด
Imports System.Data
Imports System.Data.OleDb
ผิดพลาดประกาศใดขออภัยด้วยครับ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2010-06-21 22:19:47 |
By :
redmonkey12 |
View :
5281 |
Reply :
22 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ประกาศตัวแปร
dim conn as new OleDbConnection("Provider = Microsoft.jet.OleDb.4.0;data source ="& server.mapPath("ตำแหน่งของ database"))
dim comm as new OleDbCommand(insert into ชื่อTable (ชื่อfield1,ชื่อfield2) Values (ชื่อTextbox1.text,ชื่อTextbox2.text),conn)
แล้วก็ใช้คำสั่ง
conn.open
comm.ExecuteNonQuery
conn.close
มีกี่ filed กี่ textbox ก็ใส่เข้าไปให้หมด
|
 |
 |
 |
 |
Date :
2010-06-22 15:09:32 |
By :
whiteshark |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Public Class addst
Const database_file As String = "C:\database.mdb"
Dim strConnection As String = "provider=microsoft.Jet.Oledb.4.0;" & _
"Data Source=" & database_file
Dim conn As New OleDbConnection(strConnection)
Dim cmd As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Code (VB.NET)
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If txtnum.Text <> "" And txtname.Text <> "" And txtaddress.Text <> "" And txtday.Text <> "" And txtid.Text <> "" And txtphone.Text <> "" And txtschool.Text <> "" Then
Dim cd As String = "SELECT * FROM studen"
Dim upd As String = "INSERT INTO student (Idcard,Lname,Idtest,Address,School,birthday,phone)" & _
" VALUES ( '" & txtid.Text & "'," & _
"'" & txtname.Text & "'," & _
"'" & txtnum.Text & "'," & _
"'" & txtaddress.Text & "'," & _
"'" & txtschool.Text & "'," & _
"'" & txtday.Text & "'," & _
"'" & txtphone.Text & "')"
Dim cm As New OleDbCommand(upd, conn)
conn.Open()
cm.ExecuteNonQuery()
MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้วคะ", " my", MessageBoxButtons.OK, MessageBoxIcon.Information)
conn.Close()
Else
MsgBox("กรุณากรอกข้อมูลให้ครบค่ะ", MsgBoxStyle.Information, "Information")
End If
End Sub
แปลงเอานะค่ะพวกตารางฐานข้อมูล ของเรากับเธอจะไม่เหมือนกัน
พอดีทำโปรเจกจบ ยังไม่เสรจเลย ถ้าช่วยได้จะช่วยนะ
|
 |
 |
 |
 |
Date :
2010-06-22 23:59:59 |
By :
kikunwa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับครับเดี่ยวผมจะลองดูก่อนนะครับถ้าติดตรงไหนจะรบกวนถามอีกครับ
ขอบคุณมากครับ
|
 |
 |
 |
 |
Date :
2010-06-23 01:21:23 |
By :
redmonkey12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จิงๆแล้ว บบรรทัดที่ 6 ไม่ใช้ก็ด้ายนะลบออกไปเลยก็ด้าย ลืมหน่ะ มึนๆ
เราลองแล้ว มีไม่มีก็รันได้ บันทึกลงฐานข้อมูลได้
|
 |
 |
 |
 |
Date :
2010-06-23 02:03:07 |
By :
kikunwa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีปัญหาเเล้วครับ
|
 |
 |
 |
 |
Date :
2010-06-23 02:34:39 |
By :
redmonkey12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System.Data
Imports System.Data.OleDb
Public Class addst
Const database_file As String = "C:\ร้านขายยางรถยนต์.mdb"
Dim strConnection As String = "provider=microsoft.Jet.Oledb.4.0;" & _
"Data Source=" & database_file
Dim conn As New OleDbConnection(strConnection)
Dim cmd As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
End Class
Public Class Form3
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
Form4.Show()
Form4.Focus()
End Sub
Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
Form5.Show()
Form5.Focus()
End Sub
Private Sub ToolStripButton10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton10.Click
Form6.Show()
Form6.Focus()
End Sub
Private Sub ToolStripButton11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton11.Click
Form7.Show()
Form7.Focus()
End Sub
Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
Form8.Show()
Form8.Focus()
End Sub
Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
Form9.Show()
Form9.Focus()
End Sub
Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
Form10.Show()
Form10.Focus()
End Sub
Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton7.Click
Form11.Show()
Form11.Focus()
End Sub
Private Sub ToolStripButton8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton8.Click
Form12.Show()
Form12.Focus()
End Sub
Private Sub ToolStripButton9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton9.Click
If MsgBox("คุณต้องการออกจากโปรแกรมนี้ ใช่หรือไม่?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "คำถาม") = MsgBoxResult.Yes Then
End
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("กรุณากรอกข้อมูล วัน/เดือน/ปี ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox1.Focus()
ElseIf TextBox3.Text = "" Then
MsgBox("กรุณากรอก ชื่อ ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox3.Focus()
ElseIf TextBox4.Text = "" Then
MsgBox("กรุณากรอก นามสกุล ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox4.Focus()
ElseIf ComboBox1.Text = "" Then
MsgBox("กรุณากรอก เพศ ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
ComboBox1.Focus()
ElseIf TextBox5.Text = "" Then
MsgBox("กรุณากรอก รหัสประจำตัวประชาชน ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox5.Focus()
ElseIf TextBox6.Text = "" Then
MsgBox("กรุณากรอก วันเกิด ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox6.Focus()
ElseIf TextBox7.Text = "" Then
MsgBox("กรุณากรอก บ้านเลขที่ ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox7.Focus()
ElseIf TextBox8.Text = "" Then
MsgBox("กรุณากรอก แขวง/ตำบล ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox8.Focus()
ElseIf TextBox9.Text = "" Then
MsgBox("กรุณากรอก เขต/อำเภอ ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox9.Focus()
ElseIf TextBox10.Text = "" Then
MsgBox("กรุณากรอก จังหวัด ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox10.Focus()
ElseIf TextBox11.Text = "" Then
MsgBox("กรุณากรอก รหัสไปรษณีย์", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox11.Focus()
ElseIf TextBox12.Text = "" Then
MsgBox("กรุณากรอก เบอร์โทรศัพท์", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox12.Focus()
ElseIf TextBox13.Text = "" Then
MsgBox("กรุณากรอกวันหมดอายุ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "ข้อมูลไม่ครบ !")
TextBox13.Focus()
ElseIf MsgBox("คุณต้องการบันทึกใช่หรือไม่", MsgBoxStyle.Question + MsgBoxStyle.YesNo, " SAVE! ") = MsgBoxResult.Yes Then
ElseIf TextBox1.Text <> "" And TextBox3.Text <> "" And TextBox4.Text <> "" And ComboBox1.Text <> "" And TextBox5.Text <> "" And TextBox6.Text <> "" And TextBox7.Text <> "" And TextBox8.Text <> "" And TextBox9.Text <> "" And TextBox10.Text <> "" And TextBox11.Text <> "" And TextBox12.Text <> "" And TextBox13.Text <> "" Then
Dim cd As String = "SELECT * FROM MEMBER_S"
Dim upd As String = "INSERT INTO MEMBERS (Id_Member,Date,Sex,NameF_member,NameL_meber,Code_People,Birthday,Address,Didtrict,Sub_Didtrict,Province,Code_post,Phone,Overday)"" VALUES ( '" & TextBox1.Text & "',""'" & TextBox3.Text & "',""'" & TextBox4.Text & "',""'" & ComboBox1.Text & "',""'" & TextBox5.Text & "',""'" & TextBox6.Text & "',""'" & TextBox7.Text & "',""'" & TextBox8.Text & "',""'" & TextBox9.Text & "',""'" & TextBox10.Text & "',""'" & TextBox11.Text & "',""'" & TextBox12.Text & "',""'" & TextBox13.Text & "')"
Dim cm As New OleDbCommand(upd, conn)
conn.Open()
cm.ExecuteNonQuery()
conn.Close()
End If
End Sub
Private Sub ขอมลลกคาปลกToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลลกคาปลกToolStripMenuItem.Click
Form13.Show()
Form13.Focus()
Hide()
End Sub
Private Sub ขอมลลกคาสงToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลลกคาสงToolStripMenuItem.Click
Form14.Show()
Form14.Focus()
Hide()
End Sub
Private Sub ขอมลสนคาToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลสนคาToolStripMenuItem.Click
Form15.Show()
Form15.Focus()
Hide()
End Sub
Private Sub ขอมลขายปลกToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลขายปลกToolStripMenuItem.Click
Form16.Show()
Form16.Focus()
Hide()
End Sub
Private Sub ขอมลขายสงToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลขายสงToolStripMenuItem.Click
Form17.Show()
Form17.Focus()
Hide()
End Sub
Private Sub ขอมลการเครมปลกToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลการเครมปลกToolStripMenuItem.Click
Form18.Show()
Form18.Focus()
Hide()
End Sub
Private Sub ขอมลการเครมสงToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลการเครมสงToolStripMenuItem.Click
Form19.Show()
Form19.Focus()
Hide()
End Sub
Private Sub ProgrammerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgrammerToolStripMenuItem.Click
Form20.Show()
Form20.Focus()
Hide()
End Sub
End Class
|
 |
 |
 |
 |
Date :
2010-06-23 02:38:41 |
By :
redmonkey12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บรรทัดที่4-12 พอใส่ Public Class addst หน้าDesign หายเลยครับ
เเล้วก็บรรทัดที่ 127กับ133มันบอก Name'conn' is not declaredครับ
มันคือรายหรอครับ Public Class addst เเต่บรรทัดอื่นไม่ฟ้องerrorครับ
เเล้วตรงDataGridViewอ่าครับพอสร้างเเล้วให้editข้อมูลมาลงเลยเปล่าครับ
โดยจะทำการติดต่อdata baseให้เลยครับ
หรือว่าผิดตรงไหนช่วยเเนะนำด้วยครับ ขอบคุณครับมัน
|
 |
 |
 |
 |
Date :
2010-06-23 02:46:29 |
By :
redmonkey12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าคุณ kikunwa อ่านอยู่ ณ ขณะนี้
นอนก่อนก็ได้ครับ มันจะตี3เเล้ว
ถ้าหลับไปเเล้วก็ ขอให้ฝันดีครับ
เเละขอบคุณสำหรับเเนวทางและcodeครับ
พอดีจะทำโปรเจ๊คตัวจบที่รามครับ
ก็กำลังพยายามศึกษาอยู่ครับ
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2010-06-23 02:56:42 |
By :
redmonkey12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Const database_file As String = "C:\ร้านขายยางรถ ยนต์.mdb"
Const database_file As String = "TireShop.mdb" 'แก้เป็น ภาษาอังกริดสักนิสดีปะคะ
====================================================
ถ้าเป็น .ACCDB << ไฟล์ของ ACCESS 2007 ค่ะ
ใช้ Connection String แบบนี้
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;
|
 |
 |
 |
 |
Date :
2010-06-23 03:13:30 |
By :
blurEyes |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ใช่เฉพาะชื่อ db นะที่เป็นภาษาไทย
ชื่อ sub ยังเป็นภาษาไทยเลย ใช้เป็นแบบ comment จะดีกว่านะ
ปล. ด้านบนนะเชียร์คู่ไหน นอนดึกจริง
|
 |
 |
 |
 |
Date :
2010-06-23 08:40:24 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)โค๊ดพวกนี้ไปประกาศไว้ที่คาสของหน้า ฟอร์ม สร้างออบเจ็กต์
Const database_file As String = "C:\ร้านขายยางรถยนต์.mdb"
Dim strConnection As String = "provider=microsoft.Jet.Oledb.4.0;" & _
"Data Source=" & database_file
Dim conn As New OleDbConnection(strConnection)
Dim cmd As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
เอาโค๊ดข้างบนไปวา'ใน Public Class Form3
ของนาย นะ งืมๆ
|
 |
 |
 |
 |
Date :
2010-06-23 11:43:56 |
By :
kikunwa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณทุกท่านครับ
ตอบคุณkikunwa ตรงนี้เข้าใจเเล้ว getตอนปิดคอมพอดี อิอิ
เเต่มันไม่saveอ่าครับ โค๊ดก็ไม่เเสดงerrorครับตอนนี้กำหลังนั่งดูว่าเขียน
ผิดตรงไหนอยู่ครับ ใช้data GridView เเล้วdata GridView นี้ต้องeditข้อมูลเข้ามาเลยไม๊ครับ
ถ้าเข้าจะต้องไปเพิ่มโค๊ดด้วยรึเปล่าครับ
|
 |
 |
 |
 |
Date :
2010-06-23 12:23:12 |
By :
redmonkey12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System.Data
Imports System.Data.OleDb
Public Class Form3
Const database_file As String = "C:\TireShop.mdb"
Dim strConnection As String = "provider=microsoft.Jet.Oledb.4.0;" & _
"Data Source=" & database_file
Dim conn As New OleDbConnection(strConnection)
Dim cmd As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
Form4.Show()
Form4.Focus()
Hide()
End Sub
Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
Form5.Show()
Form5.Focus()
Hide()
End Sub
Private Sub ToolStripButton10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton10.Click
Form6.Show()
Form6.Focus()
Hide()
End Sub
Private Sub ToolStripButton11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton11.Click
Form7.Show()
Form7.Focus()
Hide()
End Sub
Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
Form8.Show()
Form8.Focus()
Hide()
End Sub
Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
Form9.Show()
Form9.Focus()
Hide()
End Sub
Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
Form10.Show()
Form10.Focus()
Hide()
End Sub
Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton7.Click
Form11.Show()
Form11.Focus()
Hide()
End Sub
Private Sub ToolStripButton8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton8.Click
Form12.Show()
Form12.Focus()
Hide()
End Sub
Private Sub ToolStripButton9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton9.Click
If MsgBox("คุณต้องการออกจากโปรแกรมนี้ ใช่หรือไม่?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "คำถาม") = MsgBoxResult.Yes Then
End
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text <> "" And TextBox2.Text <> "" And ComboBox1.Text <> "" And TextBox3.Text <> "" And TextBox4.Text <> "" And TextBox5.Text <> "" And TextBox6.Text <> "" Then
Dim cd As String = "SELECT * FROM MEMBER1"
Dim upd As String = "INSERT INTO MEMBER1 (Date1,Id_Member1,Sex,NameF_member,NameL_meber,Code_People,Birthday)" & _
" VALUES ( '" & TextBox1.Text & "'," & _
"'" & TextBox2.Text & "'," & _
"'" & ComboBox1.Text & "'," & _
"'" & TextBox3.Text & "'," & _
"'" & TextBox4.Text & "'," & _
"'" & TextBox5.Text & "'," & _
"'" & TextBox6.Text & "')"
Dim cm As New OleDbCommand(upd, conn)
conn.Open()
cm.ExecuteNonQuery() 'เเถวนี้เป็นแทบสีเหลืองครับ'
MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้ว", " my", MessageBoxButtons.OK, MessageBoxIcon.Information)
conn.Close()
Else
MsgBox("กรุณากรอกข้อมูลให้ครบ", MsgBoxStyle.Information, "Information")
End If
End Sub
Private Sub ขอมลลกคาปลกToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลลกคาปลกToolStripMenuItem.Click
Form13.Show()
Form13.Focus()
Hide()
End Sub
Private Sub ขอมลลกคาสงToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลลกคาสงToolStripMenuItem.Click
Form14.Show()
Form14.Focus()
Hide()
End Sub
Private Sub ขอมลสนคาToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลสนคาToolStripMenuItem.Click
Form15.Show()
Form15.Focus()
Hide()
End Sub
Private Sub ขอมลขายปลกToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลขายปลกToolStripMenuItem.Click
Form16.Show()
Form16.Focus()
Hide()
End Sub
Private Sub ขอมลขายสงToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลขายสงToolStripMenuItem.Click
Form17.Show()
Form17.Focus()
Hide()
End Sub
Private Sub ขอมลการเครมปลกToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลการเครมปลกToolStripMenuItem.Click
Form18.Show()
Form18.Focus()
Hide()
End Sub
Private Sub ขอมลการเครมสงToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ขอมลการเครมสงToolStripMenuItem.Click
Form19.Show()
Form19.Focus()
Hide()
End Sub
Private Sub ProgrammerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgrammerToolStripMenuItem.Click
Form20.Show()
Form20.Focus()
Hide()
End Sub
End Class
cm.ExecuteNonQuery() เเถวนี้เป็นแทบสีเหลืองครับ
เป็นเพราะอะไรหรอครับ
|
 |
 |
 |
 |
Date :
2010-06-23 17:34:44 |
By :
redmonkey12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนช่วยแก้ชื่อ control กับ method ให้เป็นภาษาอังกฤษก่อนครับ เห็นแล้วมันจิ๊ด
|
 |
 |
 |
 |
Date :
2010-06-23 17:53:06 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไว้พรุ่งนี้ละกันนะ ตอนนี้ไม่ไหว
งงกะโปรเจกของตัวเองอยุ่ อ่านะ
|
 |
 |
 |
 |
Date :
2010-06-24 04:26:41 |
By :
kikunwa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดีนะ ที่ผมทำจบแล้ว...แหะๆ
|
 |
 |
 |
 |
Date :
2010-06-24 18:07:20 |
By :
กิตติ์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System.Data
Imports System.Data.OleDb
Public Class Form2
Const database_file As String = "C:\database.mdb"
Dim strConnection As String = "provider=microsoft.Jet.Oledb.4.0;" & _
"Data Source=" & database_file
Dim conn As New OleDbConnection(strConnection)
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim WithEvents objCurrencymanager As CurrencyManager
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strsql As String = "SELECT Idtest FROM STUDENT"
da.SelectCommand = New OleDbCommand(strsql, conn)
Try
da.Fill(ds, "stu")
Catch ex As OleDbException
MsgBox("เกิดข้อผิดพลาด ", MsgBoxStyle.Critical, "Critical")
Exit Sub
End Try
TextBox1.DataBindings.Add("Text", ds.Tables("stu"), "FirstName")
TextBox2.DataBindings.Add("Text", ds.Tables("stu"), "LastName")
DateTimePicker1.DataBindings.Add("Value", ds.Tables("stu"), "Birthday")
DataGridView1.DataSource = ds.Tables("stu") 'ผูกตาราง กับ datadagrid
objCurrencymanager = Me.BindingContext(ds.Tables("stu"))
objCurrencymanager_PositionChanged(Nothing, Nothing)
End Sub
Private Sub objCurrencymanager_PositionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles objCurrencymanager.PositionChanged
Label1.Text = "เรคอร์ดที่" & objCurrencymanager.Position + 1 & _
"จากทั้งหมด" & objCurrencymanager.Count & "เรคคอร์ด"
End Sub
Private Sub btadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btadd.Click
objCurrencymanager.AddNew()
TextBox1.Focus()
End Sub
Private Sub btdele_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btdele.Click
If MsgBox("แน่ใจหรือว่าต้องการลบเรคอร์ดนี้?", MsgBoxStyle.Question + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
objCurrencymanager.RemoveAt(objCurrencymanager.Position)
End If
objCurrencymanager_PositionChanged(Nothing, Nothing)
End Sub
Private Sub btsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsave.Click
Try
Dim cb As New OleDbCommandBuilder(da)
objCurrencymanager.EndCurrentEdit()
Dim irecord As Integer = da.Update(ds, "stu")
MsgBox("บันทึกการเปลี่ยนแปลงเรียบร้อยแล้ว" & ControlChars.CrLf & _
"มีการเพิ่มข้อมูล" & irecord & "เรคอร์ด")
Catch ex As OleDbException
MsgBox(ex.Message)
End Try
End Sub
End Class
น่าจะรู้นะว่าโค๊ด นี้ใส่ส่วนไหนบ้าง ไม่ใช่กอปไปวางทั้งหมด
เหมือนอันที่แล้ว ทำมาให้แล้วนะ ถ้ายังไม่ได้อีก
ไม่รู้จะทำไงแล้วนะ เหอ
|
 |
 |
 |
 |
Date :
2010-06-24 18:59:19 |
By :
kikunwa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ คุณ kikunwa มากครับสำหรับตัวโค๊ด
และขอโทษถ้าทำไรเเล้วขัดลูกกระตาในการเขียนโค๊ดครับ
ผมจะพยายามครับ ขอบคุณมากครับ
|
 |
 |
 |
 |
Date :
2010-06-24 21:01:28 |
By :
redmonkey12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สู้ต่อไป ทาเคชิ
โปเจกเราก็ยังไม่เสรจอ่ะ
ชีวิตไม่สิ้นก็ดิ้นกัลไป
สู้ๆ
|
 |
 |
 |
 |
Date :
2010-06-24 21:16:47 |
By :
kikunwa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดีครับผมทำโปรเจ็กเหมือนกันแต่ติด error เลยหยุดไว้ยังมีคนใช้เวปนี้อยู่ป่าว ยกมือหน่อยขอคำชี้เเนะ
|
 |
 |
 |
 |
Date :
2011-04-30 09:42:45 |
By :
ิbass |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
oracle ไปเลยครับ
|
 |
 |
 |
 |
Date :
2011-12-23 11:35:06 |
By :
cukar_dog |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|