Re: Help with first VB application - Data Entry form
- From: "jeff" <jhersey at allnorth dottt com>
- Date: Wed, 9 Aug 2006 05:03:20 -0700
Comment...
Getting the Date / Time from the 'client' machine can lead to 'false' date /
time stamping...ie the user has messed with the system clock and so on ...
If this time will be used for control / report purposes, I would recommend
either ...
a. Have the database fill the datetime stamp with a default obtained from
the server ...
b. Create a function to get the current date / time from the server or a
common source.
Question - What do you considered the 'Time Stamp' for the scan ... when
item is scanned or when the record is saved ... if scanned, you will need to
get the date from a common source ... if saved, set the default value in the
data table to get the current date time on the server and only issue an
insert with the text field... and let the server fill the date/time stamp.
Jeff.
PS:
b: - Get a data from a common place...
Assuming MSSQL Server Database...
SELECT GetDate();
using a ExecuteScaler on an OLEDBConnection ...
Using MSAccess...
SELECT Now();
using a ExecuteScaler on an OLEDBConnection.
<Timothy.Rybak@xxxxxxxxx> wrote in message
news:1155061620.089944.269190@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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! :)
.
- Follow-Ups:
- Re: Help with first VB application - Data Entry form
- From: Scott M.
- Re: Help with first VB application - Data Entry form
- References:
- Help with first VB application - Data Entry form
- From: Timothy . Rybak
- Help with first VB application - Data Entry form
- Prev by Date: Re: MS VB Newbie Tutorial
- Next by Date: Re: Must call RemoveHandler after AddHandler?
- Previous by thread: Re: Help with first VB application - Data Entry form
- Next by thread: Re: Help with first VB application - Data Entry form
- Index(es):
Loading