Monday, March 12, 2012
Question about datetime
I have a table in SQL Server 2000, a field StatDate datatype datatime, 8 all
null true
If the user do not enter a date in the text box it is returning a error type
mismatch ever though the field is set to allow Nulls.
What can I do to correct this
Thanks
DibCan you post the datetime format you are using while inserting the data?
Anith|||Check the code that generates an insert from the empty
text box. My guess: the insert is trying to put the empty
string '' into a datetime column. The empty string is not
a valid datetime string.
Steve Kass
Drew University
Dib wrote:
>Hi,
>I have a table in SQL Server 2000, a field StatDate datatype datatime, 8 al
l
>null true
>If the user do not enter a date in the text box it is returning a error typ
e
>mismatch ever though the field is set to allow Nulls.
>What can I do to correct this
>Thanks
>Dib
>
>|||There is no format, however when the form loads if the field is blank I am
inserting "" empty string to the textbox,
if you think this is the problem how can I correct it, When in Debug Mode
the textbox is an "" empty string.
Thanks
Dib
"Steve Kass" <skass@.drew.edu> wrote in message
news:uCEVMAMKFHA.2728@.TK2MSFTNGP10.phx.gbl...
> Check the code that generates an insert from the empty
> text box. My guess: the insert is trying to put the empty
> string '' into a datetime column. The empty string is not
> a valid datetime string.
> Steve Kass
> Drew University
> Dib wrote:
>
all
type|||I don't know. If there is a newsgroup specific to the particular front
end you are using to create this form and connect it with the database,
that might be a better place to ask. If you want a SQL Server solution,
the best I can suggest is to insert into a varchar-type column in a
staging table or use an instead of trigger to capture the form
information and generate an insert after turning '' into NULL. But
neither of these is as good a solution finding a way to create the
correct insert statement. I would expect most front-end programs to
have some kind of control that corresponds more directly to SQL Server
datetime than just a string/text control.
SK
Dib wrote:
>There is no format, however when the form loads if the field is blank I am
>inserting "" empty string to the textbox,
>if you think this is the problem how can I correct it, When in Debug Mode
>the textbox is an "" empty string.
>Thanks
>Dib
>"Steve Kass" <skass@.drew.edu> wrote in message
>news:uCEVMAMKFHA.2728@.TK2MSFTNGP10.phx.gbl...
>
>all
>
>type
>
>
>|||Thanks
Dib
"Steve Kass" <skass@.drew.edu> wrote in message
news:ePzRSXMKFHA.2764@.tk2msftngp13.phx.gbl...
> I don't know. If there is a newsgroup specific to the particular front
> end you are using to create this form and connect it with the database,
> that might be a better place to ask. If you want a SQL Server solution,
> the best I can suggest is to insert into a varchar-type column in a
> staging table or use an instead of trigger to capture the form
> information and generate an insert after turning '' into NULL. But
> neither of these is as good a solution finding a way to create the
> correct insert statement. I would expect most front-end programs to
> have some kind of control that corresponds more directly to SQL Server
> datetime than just a string/text control.
> SK
> Dib wrote:
>
am
8|||You cannot insert "" into a datefield. What I usually do is create a stored
procedure to do the insert with input variables defined that have a default
value of Null. Then from the form, I only send those fields which have a
value. The insert statment in the SP will then give the value of Null to any
variables not sent and insert a Null value into the table for that field.
If you don't want to use an SP, have the form specifically send Null as the
value for the field.
"Dib" wrote:
> Hi,
> I have a table in SQL Server 2000, a field StatDate datatype datatime, 8 a
ll
> null true
> If the user do not enter a date in the text box it is returning a error ty
pe
> mismatch ever though the field is set to allow Nulls.
> What can I do to correct this
> Thanks
> Dib
>
>
Monday, February 20, 2012
Question
In SqlServer, What is the datatype to mask a field of a table ? I mean if I want to save a password in a table, entering to SQLServer I'd want to display "*****" instead of "hello".
Thanks...
There are HTML, .NET, and Win32 controls that can be used to mask user input as they're entering some sensitive data in your application.
If, however, you want to ensure that users can't query your database for the names and passwords of all of the other users of the database, then you'll want to use any of a variety of permissions on your database.
For instance, if some operation is being done on the user's behalf, you could control the permissions on a table containing sensitive data to allow only indirect access (e.g. allow a server process to insert, update, delete from the table on the user's behalf, but disallow direct manipulation of the underlying table by the user). This obviously requires some form of strong and reliable user authentication.
You could also use row and/or column level permissions to control the amount of data that a user is able to see. For example, row level security (applied correctly) would allow everyone to perform a SELECT username, password FROM users and only see the data from rows that they had specifically been given access to.
There is lots of good documentation on establishing permissions on securables (tables, views, columns, etc.) in the SQL Server Books Online. There is also an excellent article on this subject at: http://www.microsoft.com/technet/prodtechnol/sql/2005/multisec.mspx