帮助第一个VB应用程序 - 数据输入表单 [英] Help with first VB application - Data Entry form

查看:49
本文介绍了帮助第一个VB应用程序 - 数据输入表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


这是我第一次尝试申请,所以小孩手套很高兴。


我需要制作一个只有少数元素的非常简单的形式。一个是

TraceCode - 用户扫描标签时填充的文本字段。

另一个是ScanDate - 日期/时间字段应该等于

扫描日期/时间(例如7/31/2006 5:00:00 AM)。


单击按钮或按下Enter键时键盘(或作为扫描的最后一个字符

),数据应该传输到

SQL表,并且应该清除两个文本字段并准备好

下次扫描。


目前,我有一个简单的表格,但您必须手动输入

ScanDate。此外,更新成功后,这些字段不清楚。


理想情况下,用户只能使用一个文本框,而

时他们扫描TraceCode,ScanDate会自动填充,

数据被转换到SQL表,并且字段清晰,准备好

用于下一次扫描。


这是我唯一的代码,它是针对GO的。按钮:


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click

Dim objConnection As New SqlClient.SqlConnection _

(" server = .; database = SafetyStock; trusted_connection = true")

Dim objCommand As New SqlClient.SqlCommand (",objconnection)

Dim objTransaction As SqlClient.SqlTransaction,strSQL As

String


试试


objConnection.Open()

objTransaction = objConnection.BeginTransaction


objCommand.Transaction = objTransaction


strSQL =" INSERT INTO ActiveSafetyStock(ScanDate,

TraceCode)" &安培; _

" VALUES(''"& txtDatetime.Text&"'',''"&

txtTraceCode.Text&" '')"

objCommand.CommandText = strSQL

objCommand.ExecuteNonQuery()


objTransaction.Commit()

objConnection.Close()


Catch

Button1.Text =" Failed"

objTransaction。回滚()

objConnection.Close()


结束尝试

结束子

结束班


请帮助! :)

Hello all,

This is my first attempt at an application, so kid gloves are
appreciated.

I need to make a very simple form that only has a few elements. One is
TraceCode - a text field that is populated when a user scans a label.
The other is ScanDate - a date/time field that should equal the
date/time of the scan (e.g. 7/31/2006 5:00:00 AM).

When a button is clicked, or Enter is pressed on the keyboard (or as
the last character of the scan), the data should be transmitted to a
SQL table, and the two text field should be cleared and ready for the
next scan.

Currently, I have a simple form, but you have to manually type the
ScanDate. Also, the fields don''t clear after the update is successful.

Ideally, there would only be one textbox available to the user, and
when they scan the TraceCode, the ScanDate is automatically populated,
the data is transacted to the SQL table, and the fields clear, ready
for the next scan.

Here is the only code I have, and it is for the "GO" button":

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objConnection As New SqlClient.SqlConnection _
("server=.;database=SafetyStock;trusted_connection =true")
Dim objCommand As New SqlClient.SqlCommand("", objconnection)
Dim objTransaction As SqlClient.SqlTransaction, strSQL As
String

Try

objConnection.Open()
objTransaction = objConnection.BeginTransaction

objCommand.Transaction = objTransaction

strSQL = "INSERT INTO ActiveSafetyStock(ScanDate,
TraceCode) " & _
"VALUES(''" & txtDatetime.Text & "'', ''" &
txtTraceCode.Text & "'')"
objCommand.CommandText = strSQL
objCommand.ExecuteNonQuery()

objTransaction.Commit()
objConnection.Close()

Catch
Button1.Text = "Failed"
objTransaction.Rollback()
objConnection.Close()

End Try
End Sub
End Class

Please HELP! :)

推荐答案

你的问题究竟是什么?

< Ti **** *******@gmail.com在留言中写道

news:11 ********************** @ p79g2000cwp.googlegr oups.com ...
What, exactly, is your question?
<Ti***********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...

大家好,


这是我第一次尝试申请,所以孩子的手套是

赞赏。


我需要制作一个只有少数元素的非常简单的表格。一个是

TraceCode - 用户扫描标签时填充的文本字段。

另一个是ScanDate - 日期/时间字段应该等于

扫描日期/时间(例如7/31/2006 5:00:00 AM)。


单击按钮或按下Enter键时键盘(或作为扫描的最后一个字符

),数据应该传输到

SQL表,并且应该清除两个文本字段并准备好

下次扫描。


目前,我有一个简单的表格,但您必须手动输入

ScanDate。此外,更新成功后,这些字段不清楚。


理想情况下,用户只能使用一个文本框,而

时他们扫描TraceCode,ScanDate会自动填充,

数据被转换到SQL表,并且字段清晰,准备好

用于下一次扫描。


这是我唯一的代码,它是针对GO的。按钮:


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click

Dim objConnection As New SqlClient.SqlConnection _

(" server = .; database = SafetyStock; trusted_connection = true")

Dim objCommand As New SqlClient.SqlCommand (",objconnection)

Dim objTransaction As SqlClient.SqlTransaction,strSQL As

String


试试


objConnection.Open()

objTransaction = objConnection.BeginTransaction


objCommand.Transaction = objTransaction


strSQL =" INSERT INTO ActiveSafetyStock(ScanDate,

TraceCode)" &安培; _

" VALUES(''"& txtDatetime.Text&"'',''"&

txtTraceCode.Text&" '')"

objCommand.CommandText = strSQL

objCommand.ExecuteNonQuery()


objTransaction.Commit()

objConnection.Close()


Catch

Button1.Text =" Failed"

objTransaction。回滚()

objConnection.Close()


结束尝试

结束子

结束班


请帮助! :)
Hello all,

This is my first attempt at an application, so kid gloves are
appreciated.

I need to make a very simple form that only has a few elements. One is
TraceCode - a text field that is populated when a user scans a label.
The other is ScanDate - a date/time field that should equal the
date/time of the scan (e.g. 7/31/2006 5:00:00 AM).

When a button is clicked, or Enter is pressed on the keyboard (or as
the last character of the scan), the data should be transmitted to a
SQL table, and the two text field should be cleared and ready for the
next scan.

Currently, I have a simple form, but you have to manually type the
ScanDate. Also, the fields don''t clear after the update is successful.

Ideally, there would only be one textbox available to the user, and
when they scan the TraceCode, the ScanDate is automatically populated,
the data is transacted to the SQL table, and the fields clear, ready
for the next scan.

Here is the only code I have, and it is for the "GO" button":

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objConnection As New SqlClient.SqlConnection _
("server=.;database=SafetyStock;trusted_connection =true")
Dim objCommand As New SqlClient.SqlCommand("", objconnection)
Dim objTransaction As SqlClient.SqlTransaction, strSQL As
String

Try

objConnection.Open()
objTransaction = objConnection.BeginTransaction

objCommand.Transaction = objTransaction

strSQL = "INSERT INTO ActiveSafetyStock(ScanDate,
TraceCode) " & _
"VALUES(''" & txtDatetime.Text & "'', ''" &
txtTraceCode.Text & "'')"
objCommand.CommandText = strSQL
objCommand.ExecuteNonQuery()

objTransaction.Commit()
objConnection.Close()

Catch
Button1.Text = "Failed"
objTransaction.Rollback()
objConnection.Close()

End Try
End Sub
End Class

Please HELP! :)



对不起,


我需要完成上面列出的目标,但是关于VB.net,我不太了解

到达那里。我希望有人可以告诉我如何修改给定的代码以实现这些目标。


Tim


Scott M.写道:
Sorry,

I need to accomplish the goals listed up top, but I don''t know enough
about VB.net to get there. I am hoping someone can tell me how to
modify the given code to accomplish those goals.

Tim

Scott M. wrote:

究竟是什么问题?


< Ti ***** ****** @gmail.com在留言中写道

新闻:11 ********************** @ p79g2000cwp.googlegr oups .com ...
What, exactly, is your question?
<Ti***********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...

大家好,


这是我第一次尝试申请,所以小孩手套< br $> b $ b赞赏。


我需要制作一个只有少数元素的非常简单的表格。一个是

TraceCode - 用户扫描标签时填充的文本字段。

另一个是ScanDate - 日期/时间字段应该等于

扫描日期/时间(例如7/31/2006 5:00:00 AM)。


单击按钮或按下Enter键时键盘(或作为扫描的最后一个字符

),数据应该传输到

SQL表,并且应该清除两个文本字段并准备好

下次扫描。


目前,我有一个简单的表格,但您必须手动输入

ScanDate。此外,更新成功后,这些字段不清楚。


理想情况下,用户只能使用一个文本框,而

时他们扫描TraceCode,ScanDate会自动填充,

数据被转换到SQL表,并且字段清晰,准备好

用于下一次扫描。


这是我唯一的代码,它是针对GO的。按钮:


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click

Dim objConnection As New SqlClient.SqlConnection _

(" server = .; database = SafetyStock; trusted_connection = true")

Dim objCommand As New SqlClient.SqlCommand (",objconnection)

Dim objTransaction As SqlClient.SqlTransaction,strSQL As

String


试试


objConnection.Open()

objTransaction = objConnection.BeginTransaction


objCommand.Transaction = objTransaction


strSQL =" INSERT INTO ActiveSafetyStock(ScanDate,

TraceCode)" &安培; _

" VALUES(''"& txtDatetime.Text&"'',''"&

txtTraceCode.Text&" '')"

objCommand.CommandText = strSQL

objCommand.ExecuteNonQuery()


objTransaction.Commit()

objConnection.Close()


Catch

Button1.Text =" Failed"

objTransaction。回滚()

objConnection.Close()


结束尝试

结束子

结束班


请帮助! :)
Hello all,

This is my first attempt at an application, so kid gloves are
appreciated.

I need to make a very simple form that only has a few elements. One is
TraceCode - a text field that is populated when a user scans a label.
The other is ScanDate - a date/time field that should equal the
date/time of the scan (e.g. 7/31/2006 5:00:00 AM).

When a button is clicked, or Enter is pressed on the keyboard (or as
the last character of the scan), the data should be transmitted to a
SQL table, and the two text field should be cleared and ready for the
next scan.

Currently, I have a simple form, but you have to manually type the
ScanDate. Also, the fields don''t clear after the update is successful.

Ideally, there would only be one textbox available to the user, and
when they scan the TraceCode, the ScanDate is automatically populated,
the data is transacted to the SQL table, and the fields clear, ready
for the next scan.

Here is the only code I have, and it is for the "GO" button":

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objConnection As New SqlClient.SqlConnection _
("server=.;database=SafetyStock;trusted_connection =true")
Dim objCommand As New SqlClient.SqlCommand("", objconnection)
Dim objTransaction As SqlClient.SqlTransaction, strSQL As
String

Try

objConnection.Open()
objTransaction = objConnection.BeginTransaction

objCommand.Transaction = objTransaction

strSQL = "INSERT INTO ActiveSafetyStock(ScanDate,
TraceCode) " & _
"VALUES(''" & txtDatetime.Text & "'', ''" &
txtTraceCode.Text & "'')"
objCommand.CommandText = strSQL
objCommand.ExecuteNonQuery()

objTransaction.Commit()
objConnection.Close()

Catch
Button1.Text = "Failed"
objTransaction.Rollback()
objConnection.Close()

End Try
End Sub
End Class

Please HELP! :)


听起来你需要一些专门的扫描硬件&软件,

不属于.NET。

< Ti *********** @ gmail.comwrote in message

news:11 ********************** @ m79g2000cwm.googlegr oups.com ...
It sounds like you need some specialized scanning hardware & software, which
is not part of .NET.
<Ti***********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...

对不起,


我需要完成上面列出的目标,但我不太了解

关于VB.net到到达那里。我希望有人可以告诉我如何修改给定的代码以实现这些目标。


Tim


Scott M.写道:
Sorry,

I need to accomplish the goals listed up top, but I don''t know enough
about VB.net to get there. I am hoping someone can tell me how to
modify the given code to accomplish those goals.

Tim

Scott M. wrote:

>你的问题究竟是什么?

< Ti ******* ****@gmail.com在留言中写道
新闻:11 ********************** @ p79g2000cwp.googleg roups.com ...
>What, exactly, is your question?
<Ti***********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googleg roups.com...

大家好,


这是我第一次尝试申请,所以小孩手套是

赞赏。


我需要制作一个只有少量元素的非常简单的表格。一个是

TraceCode - 用户扫描标签时填充的文本字段。

另一个是ScanDate - 日期/时间字段应该等于

扫描日期/时间(例如7/31/2006 5:00:00 AM)。


单击按钮或按下Enter键时键盘(或作为扫描的最后一个字符

),数据应该传输到

SQL表,并且应该清除两个文本字段并准备好

下次扫描。


目前,我有一个简单的表格,但您必须手动输入

ScanDate。此外,更新成功后,这些字段不清楚。


理想情况下,用户只能使用一个文本框,而

时他们扫描TraceCode,ScanDate会自动填充,

数据被转换到SQL表,并且字段清晰,准备好

用于下一次扫描。


这是我唯一的代码,它是针对GO的。按钮:


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click

Dim objConnection As New SqlClient.SqlConnection _

(" server = .; database = SafetyStock; trusted_connection = true")

Dim objCommand As New SqlClient.SqlCommand (",objconnection)

Dim objTransaction As SqlClient.SqlTransaction,strSQL As

String


试试


objConnection.Open()

objTransaction = objConnection.BeginTransaction


objCommand.Transaction = objTransaction


strSQL =" INSERT INTO ActiveSafetyStock(ScanDate,

TraceCode)" &安培; _

" VALUES(''"& txtDatetime.Text&"'',''"&

txtTraceCode.Text&" '')"

objCommand.CommandText = strSQL

objCommand.ExecuteNonQuery()


objTransaction.Commit()

objConnection.Close()


Catch

Button1.Text =" Failed"

objTransaction。回滚()

objConnection.Close()


结束尝试

结束子

结束班


请帮助! :)
Hello all,

This is my first attempt at an application, so kid gloves are
appreciated.

I need to make a very simple form that only has a few elements. One is
TraceCode - a text field that is populated when a user scans a label.
The other is ScanDate - a date/time field that should equal the
date/time of the scan (e.g. 7/31/2006 5:00:00 AM).

When a button is clicked, or Enter is pressed on the keyboard (or as
the last character of the scan), the data should be transmitted to a
SQL table, and the two text field should be cleared and ready for the
next scan.

Currently, I have a simple form, but you have to manually type the
ScanDate. Also, the fields don''t clear after the update is successful.

Ideally, there would only be one textbox available to the user, and
when they scan the TraceCode, the ScanDate is automatically populated,
the data is transacted to the SQL table, and the fields clear, ready
for the next scan.

Here is the only code I have, and it is for the "GO" button":

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim objConnection As New SqlClient.SqlConnection _
("server=.;database=SafetyStock;trusted_connection =true")
Dim objCommand As New SqlClient.SqlCommand("", objconnection)
Dim objTransaction As SqlClient.SqlTransaction, strSQL As
String

Try

objConnection.Open()
objTransaction = objConnection.BeginTransaction

objCommand.Transaction = objTransaction

strSQL = "INSERT INTO ActiveSafetyStock(ScanDate,
TraceCode) " & _
"VALUES(''" & txtDatetime.Text & "'', ''" &
txtTraceCode.Text & "'')"
objCommand.CommandText = strSQL
objCommand.ExecuteNonQuery()

objTransaction.Commit()
objConnection.Close()

Catch
Button1.Text = "Failed"
objTransaction.Rollback()
objConnection.Close()

End Try
End Sub
End Class

Please HELP! :)



这篇关于帮助第一个VB应用程序 - 数据输入表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆