Showing posts with label checks. Show all posts
Showing posts with label checks. Show all posts

Tuesday, March 27, 2012

check query status

Is it possible to create an SSIS package that checks for a running Query on my SQL db?

I need to some how check my SQL server and see if there is a query running, if its running I need to set an indicator in my table for my app. This job needs to be scheduled and run nightly (which I can do). But how can I query SQL and see if the query is still running?

There is nothing specific in SSIS that can give you that info; but perhaps you can put a query that gives you that inside of an execute sql task...|||

I want to use SSIS to create the package and use the SQL Task in the package, But how can I 'ping' the sql server to verify the sql query is still running or not? That's the portion I'm stuck on.

What would that query look like? Can this even be done?

|||Your question is one of a Transact-SQL nature and as such should probably be asked over in that forum. http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=85&SiteID=1

Come back here if you need help implementing the resulting query inside SSIS.|||You can use sp_who or sys.sysprocesses to get lists of running processes. sys.sysprocesses would be easier to work with, if you are on 2005.

Sunday, March 25, 2012

Check login

Hello, everyone. I am trying to create a procedure that checks a user's login, in the database. The login is based on e-mail address and password.

How do I construct the stored procedure to check if the username and password are correct?

Thanks,

Antonio

You could either use a stored procedure, or a function.

Code Snippet


CREATE PROCEDURE dbo.VerifyLogin

( @.eMail varchar(200),

@.Pwd varchar(20)
)

AS

SELECT isnull(( SELECT DISTINCT 'Verified'
FROM MyUsersTable

WHERE ( eMail = @.eMail
AND Pwd = @.Pwd
)
), 'BOGUS' )
GO

(or)


CREATE FUNCTION dbo.fnVerifyLogin

( @.eMail varchar(200),

@.Pwd varchar(20)
)
RETURNS varchar(10)
AS

SELECT isnull(( SELECT DISTINCT 'Verified'
FROM MyUsersTable

WHERE ( eMail = @.eMail
AND Pwd = @.Pwd
)
), 'BOGUS' )
GO

|||

Just a couple of points to make about password storage in databases.

You should never store a password in a clear (unencrypted) form in a database. Preferably you should not even store it in a decryptable form, but rather a value managled by a one-way hash. SQL Server 2005 now has the HashBytes function which will perform a cryptographically valid hash operation.

It is also recommended that you not perform a straightforward hashing but rather salt the value before hashing with another value. This means adding another known piece of information to the value before hashing the combination. This has a 2-fold advantage:

It makes a brute force attack of the hash algorithm with all the possible values harder (basically impossible if the salt is different for each password). Be aware there are projects on the internet where people are building hash lists for all the characters strings up to a certain length composed of a standard set of characters (mainly alpha/digit - upper case only) for some standard hash algorithms. Good reason for using longer passwords (12+ characters) and at least one unusual character. If you use a different salt for each user (I normally use something based upon the primary ID in the User Table) then it prevents the insider attack of moving the password hash from a user whose password is known to another allowing access to the system as that user (restoring the old hash removes signs of the hack). If the salt is held as a field in the table they can move that too (though a unique constraint might make that more difficult).sql

Thursday, March 8, 2012

Check checkboxes

Hi,

I have two web pages in one web page i have 5 check boxes. For example if the user checks the Checkbox1, checkbox2 and clicks on button.

On the button click I am storing the selected checkboxes value in database lke the following:

Year Options

xxx 1

xxx 2

in the above format( user selectes checbox1, check box 2).

And in the Second Web page I am showing the 5 checkboxes but in this web page I need to check the first and second checkboxes on the page load because user selectes those two check boxes in the first web page.

my select query returning the results like this:

Options

1

2

based on options I have to check those corresponding check boxes in the second web page.

How to achive this.

Thanks in advance

Saving a user's CheckBoxList selection and re-populating the CheckBoxList from saved data:http://www.mikesdotnetting.com/Article.aspx?ArticleID=53

|||

Hello,

You need to loop thru your result set and set the checkboex to Checked on Page_Load event.

For example:

This is how you get the values and set the checkboxes to Checked.

SqlCommand cmd = new SqlCommand("Select OPtions from <Yourtable>...");

SqlDataReader reader =cmd.ExecuteReader();while( reader.Read())

{

int col = reader.GetOrdinal("Options");

int checkValue = reader.GetInt32(col);switch(checkValue)

{

case 1:

CheckBox1.Checked =true;

case 2:

CheckBox2.Checked =true;

... etc

}

}

Optionaly you can use Page.FindControl() method to get to the checkboxes (instead of using switch statement). The problem with that is that FindControl does not loop thru the Page hierarchy so if you page is complex you may have to write your own FindControl method.

Once you have that method you can call it from the Page_Load event, like this:

if (!IsPostback)
{

// Call the SetCheckBoxes method here ...

}

Hope this helps

regards,

G