Re: Help with first VB application - Data Entry form
- From: "Scott M." <s-mar@xxxxxxxxxxxxx>
- Date: Wed, 9 Aug 2006 19:09:47 -0400
I did just realize though, that you and I have been assuming 2 different
fundmental things...
I have been assuming this is an ASP.NET web application, hence my last
comment:
I did suggest this code, but this is server-side code (not client-side
JavaScript, for example) and thus, will get the time from the web server,
not the client. VB.NET code (or any .NET code for that matter) does not
function on the client.
I think you have been commenting from the point of a WinForms application.
If that is the case (the OP didn't specify), then you are correct, the code
would execute on the client.
"Scott M." <s-mar@xxxxxxxxxxxxx> wrote in message
news:ebiX1eAvGHA.724@xxxxxxxxxxxxxxxxxxxxxxx
PS... never mentioned time based PK for you to agree with ... I do not
like these and avoid them.
Well, you are in the minority on that one. Having a PK that is, in part,
time stamped is the best way to avoid data concurrency issues when doing
updates, inserts and deletes.
PPS. you suggested the client get the time stamp ... txtDate.Text =
Now.ToShortDateString
I did suggest this code, but this is server-side code (not client-side
JavaScript, for example) and thus, will get the time from the web server,
not the client. VB.NET code (or any .NET code for that matter) does not
function on the client.
"Scott M." <s-mar@xxxxxxxxxxxxx> wrote in message
news:%23fifBb$uGHA.1296@xxxxxxxxxxxxxxxxxxxxxxx
Yes, but again, I don't think anyone was suggesting the client in the
first place.
In my opinion, the database is not the place to put a time stamp of this
kind. While I agree that good primary keys are partially time based,
this is not what the OP has stated the time would be used for. The time
is going to become data that is used by the business layer of the
applicaiton. Databases should not be in charge of creating business data
in this manner.
"jeff" <jhersey at allnorth dottt com> wrote in message
news:OvnwS49uGHA.324@xxxxxxxxxxxxxxxxxxxxxxx
...exactly... my point.
what if you have multiple clients in different time zones ... multiple
web servers in different time zones ... and multiple databases servers
in different time zones... with a user from one time zone, connecting
to a web server in another and a database in a third ... and the next
time the user log-ins ... same CLIENT machine ... he hits a different
web server and different database for his next scan transaction ... you
need some type of 'control' in the date stamping ... and to me the
logical one is the Database Server.
you need to set a base line for time stamping ... and to me, relying on
the CLIENT for this, is not good practice...as per you suggestion...
Sub Button1_Click() Handles Button1.Click
txtDate.Text = Now.ToShortDateString
End Sub
I simply made a suggestion to use the database as the control date /
time 'stamper' (for lack of a better term). If you have different
databases in different time zones, when you synchronize your data ...
if you are not identifying which server the record was initially
created on, you offset you timestamps accordingly during the sync
process ... or when you build a consolidated report to include data
from other database servers in different timezones, you offset your
timestamps based on the database server's 'timezone' ...
relying on the CLIENT is poor practice and has a hard time standing up
to an audit ... unless you have a mechanism / policy in place that
controls the time on a CLIENT machines.
Just my 2 cents ... just offering a suggestion thats all.
Jeff
"Scott M." <s-mar@xxxxxxxxxxxxx> wrote in message
news:eHymO18uGHA.1224@xxxxxxxxxxxxxxxxxxxxxxx
Hold on Jeff. What if the client, web server and database are in
diffeent time zones? I don't think anyone suggested using the client
for the date, but I think the server should generate that, not the
database.
"jeff" <jhersey at allnorth dottt com> wrote in message
news:ezBzQv6uGHA.4972@xxxxxxxxxxxxxxxxxxxxxxx
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:
- References:
- Help with first VB application - Data Entry form
- From: Timothy . Rybak
- Re: Help with first VB application - Data Entry form
- From: jeff
- Re: Help with first VB application - Data Entry form
- From: Scott M.
- Re: Help with first VB application - Data Entry form
- From: jeff
- Re: Help with first VB application - Data Entry form
- From: Scott M.
- Re: Help with first VB application - Data Entry form
- From: jeff
- Re: Help with first VB application - Data Entry form
- From: Scott M.
- Help with first VB application - Data Entry form
- Prev by Date: Re: Help with first VB application - Data Entry form
- Next by Date: Re: VB2005 Hiding Windows Forms
- 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):