 |
|
เขียนโปรแแกรม กับ vb ต้องการนำโปรแกรมที่เขียนเอาไปใช้ได้จิงกับ คอมพิวเตอร์ทั่วไป ทำได้รือป่าว |
|
 |
|
|
 |
 |
|
ไม่รู้ว่าจะตอบตรงคำถามรึป่าว...
ให้ใช้วิธีทำเป็นไฟล์ exe เอาครับ..
|
 |
 |
 |
 |
Date :
2011-11-20 19:20:57 |
By :
นายก้อนหิน |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุนมากเลย คับ
แล้วยังสงสัยข้อ
5. สำหรับบาง project ที่เรียกใช้ .dll ให้ add เข้าไปครับ
จะรู้ได้งัยคับว่า งานของเราเรียกใช้ไฟล์ .dll
ดูจากตรงไหน คับ
|
 |
 |
 |
 |
Date :
2011-11-21 16:28:42 |
By :
online |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนนี้ผมทำเปนไฟล์ setup เรียบร้อยแล้ว ลงโปรแกรมเรียบร้อยแล้ว
แต่มันมีบัญหา
ในการอัพเดท ข้อมูล
ดึงข้อมูลมาอ่านสมามารถอ่านได้ แต่ พอ
จะอัพเดทข้อมูลลงตารางกลับทำไม่ได้

sql = "INSERT INTO name1 (name,timemer,seat,com)"
sql &= " VALUES ('" & TextBox2.Text & "',"
sql &= "'" & t & "',"
sql &= "'" & seat & "',"
sql &= "'" & TextBox4.Text & "')"
Dim mycommand As New OleDbCommand(sql, con)
mycommand.ExecuteNonQuery() ตรงบรรทัดเนี่ยแหละ
ผมใช้ connectionString ms access อ่านค่าอ่านมาได้ปกติ แต่เวลา INSERT ข้อมูลทำไม่ได้
con.ConnectionString = "Provider=Microsoft.ace.OLEDB.12.0;Data Source = game.accdb"
|
 |
 |
 |
 |
Date :
2011-11-21 21:09:48 |
By :
online |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
imports System.data
imports System.data.oleDb
'กรณีไม่ได้ใส่ pw DB
Dim conStr as string = "Provider=Microsoft.Ace.OleDb.12.0; Data Source= ไฟล์ฐานข้อมูล"
Dim conn as new OleDbConnection (conStr)
conn.Open()
Dim sql as string = "SELECT * FROM ตาราง"
Dim cmd as new OleDbCommand(sql, conn)
.................
.................
conn.close()
|
 |
 |
 |
 |
Date :
2011-11-22 00:16:52 |
By :
นายก้อนหิน |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สรุปว่าผมปรกาศ ConnectionString แบบนี้ใช้ไม่ได้ รือคับ
Code (VB.NET)
Imports System.Data.OleDb
Public Class add
Dim conad As New OleDbConnection
Dim mycommandad As OleDbCommand
Dim sqlad As String
Dim drad As OleDbDataReader
Dim dtad As DataTable
Private Sub add_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conad.Close()
conad.ConnectionString = "Provider=Microsoft.ace.OLEDB.12.0;Data Source = test.accdb"
conad.Open()
showdataad()
sqlad = "select * from product"
mycommandad = New OleDbCommand(sqlad, conad)
drad = mycommandad.ExecuteReader
If drad.HasRows Then
dtad = New DataTable()
dtad.Load(drad)
ComboBox1.DataSource = dtad
ComboBox1.DisplayMember = "p_size"
ComboBox1.ValueMember = "p_id"
Else
MsgBox("ไมีมีฐานข้อมูล", MsgBoxStyle.Question, "ระบบเพิ่มสินค้า")
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.Critical, "ระบบเพิ่มสินค้า")
Else
Dim sumad As Integer
sumad = 0
sqlad = "select * from product where p_id = '" & ComboBox1.SelectedValue.ToString() & "'"
mycommandad = New OleDbCommand(sqlad, conad)
drad = mycommandad.ExecuteReader
If drad.HasRows Then
drad.Read()
sumad = Val(drad("p_sum"))
End If
sumad = sumad + Val(TextBox1.Text)
sqlad = "UPDATE product SET"
sqlad &= " p_sum = " & sumad & ""
sqlad &= " WHERE (p_id = '" & ComboBox1.SelectedValue.ToString() & "')"
Try
mycommandad = New OleDbCommand(sqlad, conad)
mycommandad.ExecuteNonQuery()
MsgBox("ระบบทำการบันทึกเรียบร้อยแล้ว", MsgBoxStyle.Information, "ระบบเพิ่มสินค้า")
ComboBox1.SelectedIndex = 0
TextBox1.Clear()
showdataad()
Catch ex As Exception
MsgBox("ข้อมูลผิดพลาด", MsgBoxStyle.Question, "ระบบเพิ่มสินค้า")
End Try
End If
End Sub
Private Sub showdataad()
sqlad = "select * from product"
mycommandad = New OleDbCommand(sqlad, conad)
drad = mycommandad.ExecuteReader
If drad.HasRows Then
dtad = New DataTable()
dtad.Load(drad)
DataGridView1.DataSource = dtad
With DataGridView1
If .RowCount > 0 Then
.Columns(0).HeaderText = "ลำดับ"
.Columns(1).HeaderText = "ขนาดเสาปูน"
.Columns(2).HeaderText = "จำนวนที่เหลือ"
.Columns(0).ReadOnly = True
.Columns(1).ReadOnly = True
.Columns(2).ReadOnly = True
.Columns(0).Width = 50
.Columns(1).Width = 120
.Columns(2).Width = 100
End If
End With
Else
MsgBox("ไมีมีฐานข้อมูล", MsgBoxStyle.Question, "ระบบเพิ่มสินค้า")
End If
End Sub
End Class
|
 |
 |
 |
 |
Date :
2011-11-22 15:47:36 |
By :
online |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|