Tag: asp.net

Dynamic query and sql injects

I have a stored procedure that receives a string parameter “OrderByColumn” and builds dynamic query accordingly. This is the part of my stored procedure code: ROW_NUMBER() OVER (ORDER BY CASE WHEN @OrderByColumn=’Date’ AND @OrderDirection=0 THEN tbl_Docs.Date END ASC, CASE WHEN @OrderByColumn=’Count’ AND @OrderDirection=0 THEN tbl_Docs.Count END ASC, And in my code behind function that calls […]

Store in DB or not to store?

There are few string lists in my web application that i don’t know where to store in DB or just class. ie. I have 7 major browsers with which users enter the site. I want to save these stats thus i need to create browser column in UserLogin database. I don’t want to waste space […]

ASP.NET's AspStateTempSessions table

Using SqlServer session state provider with ASP.NET. From : http://msdn.microsoft.com/en-us/library/aa478952.aspx , the ASPStateTempSessions table’s SessionId column is made up of : “Session Id” + “Application Id”. My question is, wouldn’t “Session Id” be enough to make this column unique ? If so, is adding the “Application Id” just some additional security to make sure sessions […]

encryption in Sql and decryption in asp.net (for querystring) possible?

I have a sql job that sends email to all users everynight. It has a footer with Unsubscibe link which opens the asp.net page. As a querystring, i want to add encrypted EmailID to the link. so i can decrypt and use it to update the database. How can i use encryption in sql and […]

gridview to sql server database

is there any way to insert in bulk (i mean all gridview rows) to sql server database in single submit. its an ASP.Net app and I also want to validate data.

get full hits information of site with asp.net

i want to get daily,monthly,yearly hits ( visit count ) of my site . What is the best way to do this in asp.net ? tnx.

Checking where all Foreign key is being used

Lets say there’s a table Table1 with Primary key as “MainID” and this MainID is being used as a Foreign key in many tables. Now when I try and delete a record from Table1 who’s MainID as foreign key is being used in some child tables, then it throws this exception that “Foreign key conflict […]

Using dropdownlist selected item to search gridview?

I’ve got a gridview that populates from four tables, and the select command (shown below) is fully functional. I’d like to be able to search the gridview, and display only those rows whose “Status” column value is equivalent to the selected item on a dropdown list. I believe I have the select statement right for […]

Inserting DateTime values into database?

This seems like it should be really obvious, but how can I put a DateTime object into an MSSQL database? When I convert it to a string, it keeps adding “-7:00” at the end for the time zone offset and so the query isn’t accepted. How can I fix this?

textarea text into sql column

If I use a textbox I have no issues getting data into sql. I’d like to use a textarea with autowrap and all that. But when I change the <input type=”text” id=”au_id”> to <textarea name=”au_id”> I can’t get the .value of au_id.Value code listed below. All I want is to swap single line text box […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.