Showing posts with label dear. Show all posts
Showing posts with label dear. Show all posts

Sunday, March 25, 2012

Case Sensitive?

Dear everyone,

I am doing Login webform (C# .NET web application) with SQL Server 2000.

The staff table is to store authenticated user info.

But when I test it, I found that the password can be case insensitive, i.e. 'A0001' should be correct password, but 'a0001' can allow login.

Could anyone tell me how to solve this problem??

Thanks you very much!!


private void btnLogin_Click(object sender, System.EventArgs e)
{
//instantiate SQL connection
SqlConnection sqlConnect = new SqlConnection(connectStg);
SqlCommand selectLogin = sqlConnect.CreateCommand();

selectLogin.CommandText = "SELECT sid, type from STAFF Where sid= '" + txtId.Text + "' and pwd= '" + txtPwd.Text + "' ";

//open connectin for execution
sqlConnect.Open();

//instantiate the SqlDataReader reader
SqlDataReader loginReader = selectLogin.ExecuteReader();

//try and catch SqlException error
try
{
if(loginReader.Read())
{

// check whether the user is the role of administrator or operator
// I use GetValue(1) i.e. type field from the above select statement // if "O' then go operator page, else go to administrator page.
if (loginReader.GetValue(1).ToString().ToUpper().Equals("O"))
{
Server.Transfer("//SMS/LoginUser/SuccessLoginOper.aspx");

}
else if (loginReader.GetValue(1).ToString().ToUpper().Equals("A"))
{
Server.Transfer("//SMS/LoginUser/SuccessLoginAdmin.aspx");
}

}

else
{
//clear content of textbox and display error message
txtId.Text="";
txtPwd.Text="";
lblLoginFail.Visible = true;
lblLoginFail.Text="Login Failed!<br>" + "Ensure that ID and Password are correct!";
}

}
catch (SqlException se)
{
if (se.Number == 17)
{
lblLoginFail.Visible = true;
lblLoginFail.Text = "Could not connect to the database";
}

else
{
lblLoginFail.Visible = true;
lblLoginFail.Text = se.Message;
}

}

//close SqlDataReader and SqlConnection
loginReader.Close();
sqlConnect.Close();

You can alter the database to be case sensitive, and I think you can also do that on a per connection basis - but you'd have to check that. The other way could be to return the passwords that have matched and then double check them in c#. I sure someone has a better method.|||Case-sesitivity is determined when installing SQL Server,
try running sp_help to see the current settings.
Passwords shouldn't be stored in plaintext in the database
anyway. I suggest you have a look at the hashing functions
in .Net and use them to calculate a hash and then save that
in the database.
Then you wouldn't have to worry about case-sensitivity either.|||Thanks you for reply!!

As you said running sp_help to see the current settings, how to change the current settings of case-sensitive problems.

I recognise that the passwords should be better stored in encrypted forms. But how to encrypt it in SQL Server. I am new in web development. Could you briefly tell me how to do? Or any web reference provided?

Waiting for reply! Thanks

Roy|||::As you said running sp_help to see the current settings, how to change the current settings
::of case-sensitive problems

He DID tell you it is determined on install time. So you can not change it.

::I recognise that the passwords should be better stored in encrypted forms.

Good. You are wrong, though. Storing encrypted passwords in SQL Server is as bad as storing them plain text. Hashing is not encryption.

::But how to encrypt it in SQL Server.

Why should you?

Hash (not encrypt) the passwords on the website, then store he hashed passwords in the server.

In the SQL only ask for the user's data by user name, retrieve the password hash from the server, hash the user input and compare. Do not forget to salt your hashes, as otherwise you are totally open to a dictionary attack.

::I am new in web development.

Not to development in general? Sounds more like this. I would suggest you invest heavily into some books.|||First of all you should be aware that the case-sensitivity settings are GLOBAL to the entire SQL Server and all databases on it.
If you really want to to the change you have to rebuild the master database using
Rebuildm.exe.
Do look it up in the books online first, and don't forget to backup your database before!

For hashing password have a look at the classes:
System.Security.Cryptography.MD5
or preferrably
System.Security.Cryptography.SHA1

Thursday, March 8, 2012

Cascade Delete

Dear Prfessional
Right now I have 190 tables and there are millions of data in the database
but now I want to physically delete the Personnel from the database and when
I started delete from master table so it gave me the constraint error and in
100 of tables there are reference that personnelID, I didn't apply cascade
delete at the time of designing so is it possible that in the single query I
enabled the cascade and after that disable it, can any body tell me the
short cut of that.
Waiting for your reply
Noor
Noor,
You have some options here. The first one would be to replace your existing FK contraints with ones with ON DELETE CASCADE in them. I wouldn't recommend this though as cascade deletes should be *designed* in to your application. This could be a dangerous
route to follow as some data may be deleted by accident.
The best thing for you to do is write a query that shows you the IDs of all the other tables that need to be deleted by joining to the parent table. When you have confimed that, you can write your DELETE statement by joining to the parent. You need to sta
rt from the bottom of the hierarchy and work your way up. You can find the schema information by querying the INFORMATION SCHEMA views - or consult any database design documentation that you may have.
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
|||Ya I already done this before.
Thanks
Noor
"Mark Allison" <marka@.no.tinned.meat.mvps.org> wrote in message
news:AA7F2418-973F-44E1-BA4D-39D81A94DC81@.microsoft.com...
> Noor,
> You have some options here. The first one would be to replace your
existing FK contraints with ones with ON DELETE CASCADE in them. I wouldn't
recommend this though as cascade deletes should be *designed* in to your
application. This could be a dangerous route to follow as some data may be
deleted by accident.
> The best thing for you to do is write a query that shows you the IDs of
all the other tables that need to be deleted by joining to the parent table.
When you have confimed that, you can write your DELETE statement by joining
to the parent. You need to start from the bottom of the hierarchy and work
your way up. You can find the schema information by querying the INFORMATION
SCHEMA views - or consult any database design documentation that you may
have.
> --
> Mark Allison, SQL Server MVP
> http://www.markallison.co.uk

Thursday, February 16, 2012

Capacity Planning

Dear All
My company has asked me to come up with the amount of
space a new database will use based upon X number of
records in tables.
Is there some sort of recognised matrix I can follow, or
will I have to wing it based upon my own interpretation of
the tables and relationships ?
Thanks
PeterThis information is in SQL Server 2000 Books Online. Look up the chapter:
"Estimating the size of a database"
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Peter" <anonymous@.discussions.microsoft.com> wrote in message
news:f97601c3f222$4697f700$a001280a@.phx.gbl...
Dear All
My company has asked me to come up with the amount of
space a new database will use based upon X number of
records in tables.
Is there some sort of recognised matrix I can follow, or
will I have to wing it based upon my own interpretation of
the tables and relationships ?
Thanks
Peter|||Thank you
Peter
>--Original Message--
>This information is in SQL Server 2000 Books Online. Look
up the chapter:
>"Estimating the size of a database"
>--
>HTH,
>Vyas, MVP (SQL Server)
>http://vyaskn.tripod.com/
>Is .NET important for a database professional?
>http://vyaskn.tripod.com/poll.htm
>
>"Peter" <anonymous@.discussions.microsoft.com> wrote in
message
>news:f97601c3f222$4697f700$a001280a@.phx.gbl...
>Dear All
>My company has asked me to come up with the amount of
>space a new database will use based upon X number of
>records in tables.
>Is there some sort of recognised matrix I can follow, or
>will I have to wing it based upon my own interpretation of
>the tables and relationships ?
>Thanks
>Peter
>
>.
>

Capacity Planning

Dear All
My company has asked me to come up with the amount of
space a new database will use based upon X number of
records in tables.
Is there some sort of recognised matrix I can follow, or
will I have to wing it based upon my own interpretation of
the tables and relationships ?
Thanks
PeterThis information is in SQL Server 2000 Books Online. Look up the chapter:
"Estimating the size of a database"
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Peter" <anonymous@.discussions.microsoft.com> wrote in message
news:f97601c3f222$4697f700$a001280a@.phx.gbl...
Dear All
My company has asked me to come up with the amount of
space a new database will use based upon X number of
records in tables.
Is there some sort of recognised matrix I can follow, or
will I have to wing it based upon my own interpretation of
the tables and relationships ?
Thanks
Peter|||Thank you
Peter

>--Original Message--
>This information is in SQL Server 2000 Books Online. Look
up the chapter:
>"Estimating the size of a database"
>--
>HTH,
>Vyas, MVP (SQL Server)
>http://vyaskn.tripod.com/
>Is .NET important for a database professional?
>http://vyaskn.tripod.com/poll.htm
>
>"Peter" <anonymous@.discussions.microsoft.com> wrote in
message
>news:f97601c3f222$4697f700$a001280a@.phx.gbl...
>Dear All
>My company has asked me to come up with the amount of
>space a new database will use based upon X number of
>records in tables.
>Is there some sort of recognised matrix I can follow, or
>will I have to wing it based upon my own interpretation of
>the tables and relationships ?
>Thanks
>Peter
>
>.
>

Sunday, February 12, 2012

Can't update linked server table

Dear Sir,
I have a script which update a linked server table.
e.g.
Update <LinkedServer>.DB1.Tbl1
Set col1 = B.col1
From <LinkedServer>.DB1.Tbl1 A
inner join <local>.DB0.Tbl1 B
On A.id = B.id
It function for several month and suddently I started to recevive error:
Server: Msg 7306, Level 16, State 2, Line 1
Could not open table '"ABC_Sale_Rpt"."dbo"."Sale_Data"' from OLE DB provider
'SQLOLEDB'. The provider could not support a row lookup position. The
provider indicates that conflicts occurred with other properties or
requirements.
[OLE/DB provider returned message: Multiple-step OLE DB operation genera
ted
errors. Check each OLE DB status value, if available. No work was done.]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IOpenRowset::OpenRowset
returned 0x80040e21: [PROPID=DBPROP_BOOKMARKS VALUE=True
STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_COMMANDTIMEOUT VALUE=60
0
STATUS=DBPROPSTATUS_OK], [PROPID=Unknown PropertyID VALUE=True
STATUS=DBPROPSTATUS_OK], [PROPID=DBPROP_IRowsetLocate VALUE=True
STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_IRowsetChange VA...
Any advise to make it function again?
HenryMost times If saw this error it was based on the absence of a unique
key (e.g. primary key). Examine the table if such a key exsist. if not
create on, that SQL Server is able to look up the row that currently
should be updated.
HTH, Jens Suessmeyer.|||Did you tryed to use OPENQUERY():
http://msdn.microsoft.com/library/d...br />
5xix.asp
"Henry" wrote:

> Dear Sir,
> I have a script which update a linked server table.
> e.g.
> Update <LinkedServer>.DB1.Tbl1
> Set col1 = B.col1
> From <LinkedServer>.DB1.Tbl1 A
> inner join <local>.DB0.Tbl1 B
> On A.id = B.id
> It function for several month and suddently I started to recevive error:
> Server: Msg 7306, Level 16, State 2, Line 1
> Could not open table '"ABC_Sale_Rpt"."dbo"."Sale_Data"' from OLE DB provid
er
> 'SQLOLEDB'. The provider could not support a row lookup position. The
> provider indicates that conflicts occurred with other properties or
> requirements.
> [OLE/DB provider returned message: Multiple-step OLE DB operation gene
rated
> errors. Check each OLE DB status value, if available. No work was done.]
> OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IOpenRowset::OpenRowset
> returned 0x80040e21: [PROPID=DBPROP_BOOKMARKS VALUE=True
> STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_COMMANDTIMEOUT VALUE=
600
> STATUS=DBPROPSTATUS_OK], [PROPID=Unknown PropertyID VALUE=True
> STATUS=DBPROPSTATUS_OK], [PROPID=DBPROP_IRowsetLocate VALUE=True
> STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_IRowsetChange VA...
> Any advise to make it function again?
> Henry
>

Can't update linked server table

Dear Sir,
I have a script which update a linked server table.
e.g.
Update <LinkedServer>.DB1.Tbl1
Set col1 = B.col1
From <LinkedServer>.DB1.Tbl1 A
inner join <local>.DB0.Tbl1 B
On A.id = B.id
It function for several month and suddently I started to recevive error:
Server: Msg 7306, Level 16, State 2, Line 1
Could not open table '"ABC_Sale_Rpt"."dbo"."Sale_Data"' from OLE DB provider
'SQLOLEDB'. The provider could not support a row lookup position. The
provider indicates that conflicts occurred with other properties or
requirements.
[OLE/DB provider returned message: Multiple-step OLE DB operation generated
errors. Check each OLE DB status value, if available. No work was done.]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IOpenRowset::OpenRowset
returned 0x80040e21: [PROPID=DBPROP_BOOKMARKS VALUE=True
STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_COMMANDTIMEOUT VALUE=600
STATUS=DBPROPSTATUS_OK], [PROPID=Unknown PropertyID VALUE=True
STATUS=DBPROPSTATUS_OK], [PROPID=DBPROP_IRowsetLocate VALUE=True
STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_IRowsetChange VA...
Any advise to make it function again?
HenryMost times If saw this error it was based on the absence of a unique
key (e.g. primary key). Examine the table if such a key exsist. if not
create on, that SQL Server is able to look up the row that currently
should be updated.
HTH, Jens Suessmeyer.|||Did you tryed to use OPENQUERY():
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_oa-oz_5xix.asp
"Henry" wrote:
> Dear Sir,
> I have a script which update a linked server table.
> e.g.
> Update <LinkedServer>.DB1.Tbl1
> Set col1 = B.col1
> From <LinkedServer>.DB1.Tbl1 A
> inner join <local>.DB0.Tbl1 B
> On A.id = B.id
> It function for several month and suddently I started to recevive error:
> Server: Msg 7306, Level 16, State 2, Line 1
> Could not open table '"ABC_Sale_Rpt"."dbo"."Sale_Data"' from OLE DB provider
> 'SQLOLEDB'. The provider could not support a row lookup position. The
> provider indicates that conflicts occurred with other properties or
> requirements.
> [OLE/DB provider returned message: Multiple-step OLE DB operation generated
> errors. Check each OLE DB status value, if available. No work was done.]
> OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IOpenRowset::OpenRowset
> returned 0x80040e21: [PROPID=DBPROP_BOOKMARKS VALUE=True
> STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_COMMANDTIMEOUT VALUE=600
> STATUS=DBPROPSTATUS_OK], [PROPID=Unknown PropertyID VALUE=True
> STATUS=DBPROPSTATUS_OK], [PROPID=DBPROP_IRowsetLocate VALUE=True
> STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_IRowsetChange VA...
> Any advise to make it function again?
> Henry
>

Can't update linked server table

Dear Sir,
I have a script which update a linked server table.
e.g.
Update <LinkedServer>.DB1.Tbl1
Set col1 = B.col1
From <LinkedServer>.DB1.Tbl1 A
inner join <local>.DB0.Tbl1 B
On A.id = B.id
It function for several month and suddently I started to recevive error:
Server: Msg 7306, Level 16, State 2, Line 1
Could not open table '"ABC_Sale_Rpt"."dbo"."Sale_Data"' from OLE DB provider
'SQLOLEDB'. The provider could not support a row lookup position. The
provider indicates that conflicts occurred with other properties or
requirements.
[OLE/DB provider returned message: Multiple-step OLE DB operation generated
errors. Check each OLE DB status value, if available. No work was done.]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IOpenRowset::OpenRowset
returned 0x80040e21: [PROPID=DBPROP_BOOKMARKS VALUE=True
STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_COMMANDTIMEOUT VALUE=600
STATUS=DBPROPSTATUS_OK], [PROPID=Unknown PropertyID VALUE=True
STATUS=DBPROPSTATUS_OK], [PROPID=DBPROP_IRowsetLocate VALUE=True
STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_IRowsetChange VA...
Any advise to make it function again?
Henry
Most times If saw this error it was based on the absence of a unique
key (e.g. primary key). Examine the table if such a key exsist. if not
create on, that SQL Server is able to look up the row that currently
should be updated.
HTH, Jens Suessmeyer.
|||Did you tryed to use OPENQUERY():
http://msdn.microsoft.com/library/de...oa-oz_5xix.asp
"Henry" wrote:

> Dear Sir,
> I have a script which update a linked server table.
> e.g.
> Update <LinkedServer>.DB1.Tbl1
> Set col1 = B.col1
> From <LinkedServer>.DB1.Tbl1 A
> inner join <local>.DB0.Tbl1 B
> On A.id = B.id
> It function for several month and suddently I started to recevive error:
> Server: Msg 7306, Level 16, State 2, Line 1
> Could not open table '"ABC_Sale_Rpt"."dbo"."Sale_Data"' from OLE DB provider
> 'SQLOLEDB'. The provider could not support a row lookup position. The
> provider indicates that conflicts occurred with other properties or
> requirements.
> [OLE/DB provider returned message: Multiple-step OLE DB operation generated
> errors. Check each OLE DB status value, if available. No work was done.]
> OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IOpenRowset::OpenRowset
> returned 0x80040e21: [PROPID=DBPROP_BOOKMARKS VALUE=True
> STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_COMMANDTIMEOUT VALUE=600
> STATUS=DBPROPSTATUS_OK], [PROPID=Unknown PropertyID VALUE=True
> STATUS=DBPROPSTATUS_OK], [PROPID=DBPROP_IRowsetLocate VALUE=True
> STATUS=DBPROPSTATUS_CONFLICTING], [PROPID=DBPROP_IRowsetChange VA...
> Any advise to make it function again?
> Henry
>