我在Visual Studio 2017中构建了一个简单的应用程序,但已经卡住了。
这个想法是,使用4个相同的表来访问Access数据库。 我们称之为表:“Active-Lead-List”,“Send-Info”,“Not-Interested”,“Removed”
使用5000行记录加载“Active-Lead-List”表。
此应用程序将用于一次显示“Active-Lead-List Table”数据,1行/记录/“Lead”。
app用户会点击例如“Send-Info”,然后这将“剪切”当前显示的“Active-Lead-List”表中的相应行,并“粘贴”另一个表中的行/列“发送” -Info“表。
我设法正确导入/显示数据,使用Next和Previous按钮进入下一个/上一个。在表中记录功能正常..
但我不能为我的生活弄清楚如何处理这个看似简单却又令人痛苦的“Cut& Paste”工作!
以下是我项目的一些图片:
这是我到目前为止所做的所有代码。要在初始加载时填充表单,并且我已经完成了下一个和上一个按钮功能,并且DO按预期运行。
这些是UI的理想功能
我需要做的是,能够将当前显示的记录移动到其他任何一个表(“不感兴趣”或“发送信息”),此项目现在将完成。显然还有删除和保存功能,但我迫切需要这个解决方案,并且认真计划投入时间和$来正确学习这些编程语言,并最终完全使用更多功能重新构建并在我们办公室的本地化服务器上运行,如建议的那样之前。你们和男孩们真的很快帮我学习。我已经在这里消化了丰富的知识!谢谢!
答案 0 :(得分:1)
Private Sub btnSENDINFO_Click(sender As Object, e As EventArgs) Handles btnSENDINFO.Click
' Define variables.
Dim conn As New System.Data.OleDb.OleDbConnection("...")
Dim cmd As New System.Data.OleDb.OleDbCommand
Dim leadId As String
' Read id value from the form control.
leadId = txtIDbox.Text
' Define command for updating send_info field in active_leads.
cmd.Connection = conn
cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = "UPDATE active_leads SET send_info = TRUE WHERE id = " & leadId
conn.Open()
' Run queries.
cmd.ExecuteNonQuery()
' Close connection.
conn.Close()
End Sub
Private Sub btnNOTINTERESTED_Click(sender As Object, e As EventArgs) Handles btnNOTINTERESTED.Click
' Define variables.
Dim conn As New System.Data.OleDb.OleDbConnection("...")
Dim cmd As New System.Data.OleDb.OleDbCommand
Dim leadId As String
' Read id value from the form control.
leadId = txtIDbox.Text
' Define command for updating not_interested field in active_leads.
cmd.Connection = conn
cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = "UPDATE active_leads SET not_interested = TRUE WHERE id = " & leadId
' Open connection.
conn.Open()
' Run queries.
cmd.ExecuteNonQuery()
' Close connection.
conn.Close()
End Sub
removed_leads
的代码:Private Sub btnREMOVE_Click(sender As Object, e As EventArgs) Handles btnREMOVE.Click
' Define variables.
Dim conn As New System.Data.OleDb.OleDbConnection("...")
Dim cmd1 As New System.Data.OleDb.OleDbCommand
Dim cmd2 As New System.Data.OleDb.OleDbCommand
Dim leadId As String
' Read id value from the form control.
leadId = txtIDbox.Text
' Define command for inserting an active lead into removed_leads.
cmd1.Connection = conn
cmd1.CommandType = System.Data.CommandType.Text
cmd1.CommandText = "INSERT INTO removed_leads (active_lead_id, business_name, street_address, phone, reviews, website, email, send_info, not_interested)
SELECT al.id, al.business_name, al.street_address, al.phone, al.reviews, al.website, al.email, al.send_info, al.not_interested
FROM active_leads AS al
WHERE al.id = " & leadId
' Define command for deleting an active lead from active_leads.
cmd2.Connection = conn
cmd2.CommandType = System.Data.CommandType.Text
cmd2.CommandText = "DELETE FROM active_leads WHERE id = " & leadId
' Open connection.
conn.Open()
' Run queries.
cmd1.ExecuteNonQuery()
cmd2.ExecuteNonQuery()
' Close connection.
conn.Close()
End Sub
以下是您需要的一些链接: