Showing posts with label store. Show all posts
Showing posts with label store. Show all posts

Tuesday, March 20, 2012

cipher

hi
i'm a web application developer. i am writeing a commercial system. i want to cipher my data. i use microsoft sql server 2000 to store my data.i use ASP to develop my application.
please tell me how i cipher my database and ensure my application security.
thanks.if you're using ASP you're on the wrong site. this is an ASP.NET site. However...

as for 'cipher'ing your data, there's more to security than just ROT13ing the stuff you store in your database. you ought to sit down and read up on web application security rather than just asuming encipherment is your friend (it's not - by definition encipherment is NOT the same as encryption and is inherently breakable)

for a start-out, try www.aspin.com (they have a security section), www.badwebmasters.net, www.securityfocus.com, www.4guysfromrolla.com, www.aspfaq.com, www.developersdex.com and most importantly google. with the right keywords you'll turn up a host of information on ways to secure your ASP code.

j

Monday, March 19, 2012

Choosing the correct data types

In a typical "Order Item" table I need to store the selling price of
the item and the percentage discount applied. I'm thinking Numeric
for the price, and Float for the percentage.
Good design, or clueless?
Thanks
Edward
I would tend to opt for Numeric/Decimal for percentage as well. Why
introduce approximate numbers? Do you even need decimal places here?
(Typically discounts are 10%, 20% etc.)
<teddysnips@.hotmail.com> wrote in message
news:e4aa5937-58af-4be0-8db0-2b582c8fd7e3@.s36g2000prg.googlegroups.com...
> In a typical "Order Item" table I need to store the selling price of
> the item and the percentage discount applied. I'm thinking Numeric
> for the price, and Float for the percentage.
> Good design, or clueless?
> Thanks
> Edward
|||those will work. You could also consider using the money datatype for the
price.
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.
<teddysnips@.hotmail.com> wrote in message
news:e4aa5937-58af-4be0-8db0-2b582c8fd7e3@.s36g2000prg.googlegroups.com...
> In a typical "Order Item" table I need to store the selling price of
> the item and the percentage discount applied. I'm thinking Numeric
> for the price, and Float for the percentage.
> Good design, or clueless?
> Thanks
> Edward

Choosing the correct data types

In a typical "Order Item" table I need to store the selling price of
the item and the percentage discount applied. I'm thinking Numeric
for the price, and Float for the percentage.
Good design, or clueless?
Thanks
EdwardI would tend to opt for Numeric/Decimal for percentage as well. Why
introduce approximate numbers? Do you even need decimal places here?
(Typically discounts are 10%, 20% etc.)
<teddysnips@.hotmail.com> wrote in message
news:e4aa5937-58af-4be0-8db0-2b582c8fd7e3@.s36g2000prg.googlegroups.com...
> In a typical "Order Item" table I need to store the selling price of
> the item and the percentage discount applied. I'm thinking Numeric
> for the price, and Float for the percentage.
> Good design, or clueless?
> Thanks
> Edward|||those will work. You could also consider using the money datatype for the
price.
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.
<teddysnips@.hotmail.com> wrote in message
news:e4aa5937-58af-4be0-8db0-2b582c8fd7e3@.s36g2000prg.googlegroups.com...
> In a typical "Order Item" table I need to store the selling price of
> the item and the percentage discount applied. I'm thinking Numeric
> for the price, and Float for the percentage.
> Good design, or clueless?
> Thanks
> Edward

Choosing the correct data types

In a typical "Order Item" table I need to store the selling price of
the item and the percentage discount applied. I'm thinking Numeric
for the price, and Float for the percentage.
Good design, or clueless?
Thanks
EdwardI would tend to opt for Numeric/Decimal for percentage as well. Why
introduce approximate numbers? Do you even need decimal places here?
(Typically discounts are 10%, 20% etc.)
<teddysnips@.hotmail.com> wrote in message
news:e4aa5937-58af-4be0-8db0-2b582c8fd7e3@.s36g2000prg.googlegroups.com...
> In a typical "Order Item" table I need to store the selling price of
> the item and the percentage discount applied. I'm thinking Numeric
> for the price, and Float for the percentage.
> Good design, or clueless?
> Thanks
> Edward|||those will work. You could also consider using the money datatype for the
price.
--
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.
<teddysnips@.hotmail.com> wrote in message
news:e4aa5937-58af-4be0-8db0-2b582c8fd7e3@.s36g2000prg.googlegroups.com...
> In a typical "Order Item" table I need to store the selling price of
> the item and the percentage discount applied. I'm thinking Numeric
> for the price, and Float for the percentage.
> Good design, or clueless?
> Thanks
> Edward

Thursday, March 8, 2012

Chinese chars in SQL?

We have a need to enter and store Chinese characters in a SQL Server table.
Has anyone done this before?
We're using ASP .NET to program entry forms, so they'd have to accept
Chinese chars, the data would be stored in SQL Server, and then search
results would have to display Chinese as well.
What additional technology might we need to implement this?
Thanks!!As far as I know you may use datatype as NVarchar / Nchar.
Even if the datatype the column is Varchar / Char it should still be able to save it, provided you take care of it in UI i.e. ASP page using code-page setting.|||You would need to store data as Unicode (i.e. nvarchar) and select the
approriate Chinese collation for your data. You need to also make sure that
your application is ready to process Chinese (or other) data:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html/vxorilocalizationplanning.asp
--
Michiel Wories, SQL Server PM
This posting is provided "AS IS" with no warranties, and confers no rights.
--
"Dean J. Garrett" <deanj_garrett@.yahoo.com> wrote in message
news:Ojae0LPmDHA.372@.TK2MSFTNGP11.phx.gbl...
> We have a need to enter and store Chinese characters in a SQL Server
table.
> Has anyone done this before?
> We're using ASP .NET to program entry forms, so they'd have to accept
> Chinese chars, the data would be stored in SQL Server, and then search
> results would have to display Chinese as well.
> What additional technology might we need to implement this?
> Thanks!!
>
>|||Thank you! I'll follow your advice.
"Michiel Wories [MS]" <mwories@.online.microsoft.com> wrote in message
news:3f97f365$1@.news.microsoft.com...
> You would need to store data as Unicode (i.e. nvarchar) and select the
> approriate Chinese collation for your data. You need to also make sure
that
> your application is ready to process Chinese (or other) data:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsent7/html
/vxorilocalizationplanning.asp
> --
> Michiel Wories, SQL Server PM
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> --
> "Dean J. Garrett" <deanj_garrett@.yahoo.com> wrote in message
> news:Ojae0LPmDHA.372@.TK2MSFTNGP11.phx.gbl...
> > We have a need to enter and store Chinese characters in a SQL Server
> table.
> > Has anyone done this before?
> >
> > We're using ASP .NET to program entry forms, so they'd have to accept
> > Chinese chars, the data would be stored in SQL Server, and then search
> > results would have to display Chinese as well.
> >
> > What additional technology might we need to implement this?
> >
> > Thanks!!
> >
> >
> >
>

Chinese and Japanese characters in same colation

SQL 2000, latest SP. We currently have the need to store data from a
UTF-8 application in multiple languages in a single database.

Our findings thus far support the fact that single-byte and
double-byte characters can be held in the same DB without issue.
However, when holding two sets of DIFFERING double-byte characters
(i.e. Chinese and Japanese) there are issues.

Since Japanese has a superset of both Kanji and Katakana characters
it's our theory that the Japanese collations will hold Chinese as well
(Mandarin).

1) Has anybody tried to store multiple languages in the same db? What
collation was used?

2) Is it possible to change collation by table?

3) Which collation of Japanese should be used for best multibyte,
UTF-8 character sets? Currently we're testing with Japanese_CI_AS
(encoding MS932).

Any and all responses appreciated,

gary@.shimanoweb.comGPenn (gbpenn@.yahoo.com) writes:
> SQL 2000, latest SP. We currently have the need to store data from a
> UTF-8 application in multiple languages in a single database.

You cannot store UTF-8 data in an SQL Server database. But UTF-8 is
just an encoding form of Unicode, and in SQL Server you store Unicode
data as UTF-16.

> Since Japanese has a superset of both Kanji and Katakana characters
> it's our theory that the Japanese collations will hold Chinese as well
> (Mandarin).

Yes, Unicode unifies the Japanese and Chinese ideographs. The idea is
that if they look different, that is a font and presentation issue.

> 1) Has anybody tried to store multiple languages in the same db? What
> collation was used?
> 2) Is it possible to change collation by table?

In SQL Server you can have different collations on different columns,
so you could have

chinese_text nvarchar(23) COLLATE <some Chinese collation>
japanese_text nvarchar(23) COLLATE Japanese_xx_xx

Then whether this is a good idea, depends on your application.

> 3) Which collation of Japanese should be used for best multibyte,
> UTF-8 character sets? Currently we're testing with Japanese_CI_AS
> (encoding MS932).

That is defintely not my field of expertise, but beware that there
are also Width and Kana-sensitive variations.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Saturday, February 25, 2012

checking validity

Hello there
I've build store proecdure that create dinamic sql sentences for updating
data.
Is there a way to check if the sencence is valid before running it?Roy,shalom
Yes it is
CREATE TABLE #Test (col INT)
INSERT INTO #Test VALUES (1)
DECLARE @.str VARCHAR(50),@.col INT
SET @.col=5
SET @.str='UPDATE #Test SET col='+CAST(@.col AS VARCHAR(10))
--EXEC (@.str)
PRINT (@.str)
SELECT * FROM #Test
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:OVHrU1LUGHA.5500@.TK2MSFTNGP12.phx.gbl...
> Hello there
> I've build store proecdure that create dinamic sql sentences for updating
> data.
> Is there a way to check if the sencence is valid before running it?
>|||[Reposted, as posts from outside msnews.microsoft.com does not seem to make
it in.]
Roy Goldhammer (roy@.hotmail.com) writes:
> I've build store proecdure that create dinamic sql sentences for updating
> data.
> Is there a way to check if the sencence is valid before running it?
In SQL 2005 you could embed the query in SET PARSEONLY ON and put it in
a TRY/CATCH handler. But that will not catch all errors, like misspelled
column names or misspelled table names. I guess you can catch these if
you use SET FMTONLY ON instead, but that will produce a result set with
metadata to the client, which is likely confuse it.
Working with dynamic SQL means that you have to test carefully, and by
other means ensure that you do not generate syntax errors at run-time.
A very important tool to achieve this is that you build parameterised
queries that you run with sp_executesql. If you interpolate all values
into the SQL string and run with EXEC(), there are more risk for problems.
Also, make sure that you use quotename for all object names you interpolate
into the string.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.seBooks Online for SQL
Server 2005
athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000
athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx|||Consider SET FMTONLY ON and SET PARSEONLY ON. However, if the programming to
create the T-SQL statements is correct, then this should not be a recuring
problem.
If you are talking about dynamic SQL as in the entire structure of statement
(not just parameters) is created on the fly, then perhaps this programming
would be easier to implment on the application side. A class can be written
that exposes properties for table names, joins, column names, filter
expressions, etc. and then a few hundred lines of C# coding could assemble a
properly formatted select statement.
"Roy Goldhammer" <roy@.hotmail.com> wrote in message
news:OVHrU1LUGHA.5500@.TK2MSFTNGP12.phx.gbl...
> Hello there
> I've build store proecdure that create dinamic sql sentences for updating
> data.
> Is there a way to check if the sencence is valid before running it?
>

Sunday, February 19, 2012

Checking is updation successfull

I am updating a table in store procedure. I want to check whether the statement has successfully updated the table or not. i know in mySql i can handle it using ROW_COUNT() function. but how can i do it in MS-SQL?You can use @.@.ROWCOUNT for getting number of rows affected by the last statement.|||Hey, thanks man... you saved my time on Google :)

Sunday, February 12, 2012

CheckBoxes and SQL Server

Hello All,

I am tring to find a better why to do this. I store data in the SQL Server about whether a checkbox was checked or not and the users can come back to the page and alter it as needed. This is the code for Inserting the data. It uses Stored Procedures and I will cut out all unessary code.


myCommand.Parameter.Add("@.CheckBox", myConnection);

That Records it and I use this to retrieve it.


while (myDataReader.Read())
{
string strChecked = myDataReader["Test"];
if ( strChecked == "1" )
{
cbxPhysicalExam.Checked = true;
}
else
{
cbxPhysicalExam.Checked = false;
}
}

This work but I would much rather do this...


while (myDataReader.Read())
{
cbxPhysicalExam.Checked = myDataReader["Test"].ToString();
}

Does anyone know how to do this?

Much Thanks,
RogerDepends on the type you're using in the database. Typical, for a boolean value (that's the case for checkboxes) you use the SQL Server type 'bit'. This returns a 0 or 1 value which can be casted to a boolean value.

Hope this helps?|||OK thats what I use... but how do I code it on the return... It will not compile like this...


cbxExample.Checked = myDataReader["Example"];

I get this on attempt to compile...

Cannot implicitly convert type 'object' to 'bool'

OK... maybe I need to Explicitly convert. I do not know how convert 1 - true and 0 - false|||Yes I see, maybe I was not clear enough in my answer. The bit type in the SQL Server is far more efficient to work with when doing queries etc. How to convert 1 to true and 0 to false? You may use something like this:

cbxExample.Checked = myDataReader["Example"].ToString() == "1";

which will do the job.|||I tried that and it didn't work... Here is all the code

SQL SERVER Table - TEST

Columns - ID int - Test bit

Store Proc For Select
CREATE PROCEDURE dbo.sp_Test
AS
Select * From Test
GO

Store Proc For Insert
CREATE PROCEDURE dbo.sp_TestIns (
@.Testbit )
AS
Insert Into Test (
Test
)
Values (
@.Test
)
GO

Code Behind Page


void SaveClicked()
{
SqlCommand myCommand = new SqlCommand("sp_TestIns", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add("@.Test", cbxText.Checked);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();{
}

void Fill()
{
SqlCommand myCommand = new SqlCommand("sp_Test", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myConnection.Open();
SqlDataReader myDataReader;
myDataReader = myCommand.ExecuteReader();
while (myDataReader.Read())
{
cbxPhysicalExam.Checked = myDataReader["Test"].ToString() == "1";
}
myDataReader.Close();
myConnection.Close();
}

THis doesn't work... what am I doing wrong?|||I figured it out... Thank you for your help...

cbxTest.Checked = (bool)myDataReader["Test"];

Thanks Again...

Roger

Check to see if a table exists

I am running Sql Server 7.0 and I am using a store procedure to drop a global temp table if it exists.
Currently, it looks like this:
if object_id('##Table') is null
print 'True'
else
print 'False'
Drop Table ##tmpTable
It works fine through Query Analyzer, but when I try to execute this code through ASP code, I get the following error:
Microsoft OLE DB Provider for SQL Server error '80040e09' With the statement printing out TRUE that the table doesn't exist. And if doesn't exist, it should continue on and create the table as instructed.
Any ideas as to what I am doing wrong? Is there a better way to check as to whether or not a table exists? Any help would be appreciated.
Thanks.
Kirk
That will always execute the drop table
if object_id('##Table') is null
print 'True'
else
begin
print 'False'
Drop Table ##tmpTable
end
And think will only work if you are in tempdb - try
if object_id('tempdb..##Table') is null
print 'True'
else
begin
print 'False'
Drop Table ##tmpTable
end
"Kirk" wrote:

> I am running Sql Server 7.0 and I am using a store procedure to drop a global temp table if it exists.
> Currently, it looks like this:
> if object_id('##Table') is null
> print 'True'
> else
> print 'False'
> Drop Table ##tmpTable
> It works fine through Query Analyzer, but when I try to execute this code through ASP code, I get the following error:
> Microsoft OLE DB Provider for SQL Server error '80040e09' With the statement printing out TRUE that the table doesn't exist. And if doesn't exist, it should continue on and create the table as instructed.
> Any ideas as to what I am doing wrong? Is there a better way to check as to whether or not a table exists? Any help would be appreciated.
> Thanks.
> Kirk
>

check time range in store procedure.

I have reservation database, suppose somebody reserved a resource on 10/12/2006 from 9:00am to 12pm. If anybody else want to reserve the same resource from 10am to 3pm. It will not let them reserver. I would like to check a range in store procedure. Is there has any function to check range in easy way?
Many thanks.Check that first timepoint of second reservation attempt is not between
starting and ending timepoint of the first reservation?|||Thank you! I have another question, in the front end, i would like to have a calendar form on it, when user click the date, it would be like 10/12/2006. Also i would like to have time dropdown box, like 8:00am, 9:00am...., How to put together to be the ScheduleDate (10/12/20068:00am), use string then convert to date? In the dropdown box, Is that the format should like 8:00am, or 8am?

Thanks.|||I think you'll have to put the date and the time together
in such a way that the resulting string can be converted
(using convert or cast) to a datetime value.|||Check that first timepoint of second reservation attempt is not between
starting and ending timepoint of the first reservation?

That's a start, but leaves some holes. What if the second reservation starts before the first but ends during or after? It would pass your test but still be a conflict.|||assume
SD = start date of the range to be queried
ED = start date of the range to be queried
FD = from_date of a stored event
TD = to_date of a stored event

here are all the overlap possibilities:
SD ED
| |
1 FD--TD | |
| |
2 FD-|-TD |
| |
3 | FD--TD |
| |
4 FD-|---|-TD
| |
5 | FD-|-TD
| |
6 | | FD--TDyou want to report all events except case 1 and case 6
... where ED >= FD /* eliminates case 6 */
and SD <= TD /* eliminates case 1 */|||Nice visual; helps people see all the possibilities. I use the same solution in my apps.|||to relate this to your example in post #1 ...

stored reservation --
FD = 2006-10-12 09:00
TD = 2006-10-12 12:00

requested reservation --
SD = 2006-10-12 10:00
ED = 2006-10-12 15:00

you are looking at case #2

the query will return a row

when the query returns no rows, it means you can grant the request for a new reservation

Friday, February 10, 2012

Check Table Values in the Store Procedure...

HI

I have a problem related Store Procedure, that i am trying to extact a value from Database (Like FirstName,LastName,Email Address) through Store Procedure and Display it in the DropDownList(Like: FirstName LastName ,(xyz@.xyz.com)) , and this is working correctly.

Now i try to check the value at the same time if it is NULL value in the Database then pass EmptyString to the DropDownList Like ("" "" ,(xyz@.xyz.com))\

how i can do that in the store procedure.

Comments will be appreciated.

Use the IsNull function.

|||

You could save the results to a temp table in the stored procedure then do an update replacing all nulls with "" then just return the contents of the temp table. e.g

CREATE TABLE #tmpTable
(
field1as NVARCHAR(200),
field2as integer
)

INSERT INTO #tmpTable (field1,Field2)
SELECT * FROM SelectionTable

UPDATE #tmpTable SET field1 ="" WHERE field1 isnull

SELECT * FROM #TmpTable

DROP #tmpTable

|||

You can use the Isnull function directly in your select query like this:

select firstName , lastName ,IsNull ( email ,'' )as emailfrom <table Name>

This way you are rest assured that for whichever row the email is null, it will automatically be converted to '' ( blank string ). You can write anything like 'Not Available' in the replacement part of the isnull function.

Hope this will help.