Posts
1147
Comments
890
Trackbacks
1
May 2005 Blog Posts
How to use Trusted Connection when SQL server and web Server are on two separate machines

This is a good write-up of the steps you need to take if you have “Login failed for user (null)“ errors.

http://weblogs.asp.net/AChang/archive/2004/04/15/113866.aspx

posted @ Tuesday, May 31, 2005 9:50 AM | Feedback (2)
How to Perform a SQL Server Performance Audit

This is a great set of explanations of the various configuration settings for SQL Server 2000, what the defaults are, when you might need to change these values, etc.:

http://www.sql-server-performance.com/sql_server_performance_audit.asp

posted @ Wednesday, May 25, 2005 5:01 PM | Feedback (2)
.NET Setting TextBox Width in a DataGrid's Edit Mode

Took me a while to figure this out.  Code is in VB.NET, but easy enough to update it for C# accordingly.

In the databound event of a datagrid, look for an edit item like this:

If e.Item.ItemType = ListItemType.EditItem Then

Then find the textbox you want to work with like this:

Dim txtUserName As TextBox = CType(e.Item.Cells(dgUserListColumns.UserName).Controls(0), TextBox)

A couple of things to note here.  The name of the textbox is arbitrary, but I make it similar to the column name.  Also, I use an enum (named 'dgUserListColumns' here) to set the order of all the columns (hidden or otherwise).  This allows me to update the column list in the enum if I add or subtract a column, and not have to go through all the code and change index numbers.  Also, the index of the control will be different in different cases.  It is almost always 0, as it is here, but if you set the TextMode to Password, for instance, the control index will be 1.  Trial and error with debugging will get you the right value.

Finally, set the width like this:

txtUserName.Width = System.Web.UI.WebControls.Unit.Pixel(100)

You can't just set the width to a value by itself, as you could choose to use Pixel, Percentage, or Point.  It's up to you to decide what you want to use here.

And that's it.  I'm sure there are other ways to do it (I found other examples through Google that for whatever reason (probably user error on my part) didn't seem to work), but this does work.

posted @ Saturday, May 21, 2005 4:03 PM | Feedback (1)
Server-side Paging with SQL Server

There are many ways to do this, but here's an older article that runs through one scenario:

http://rosca.net/writing/articles/serverside_paging.asp

posted @ Friday, May 20, 2005 10:09 AM | Feedback (2)
T-SQL: Using Default Parameters in Stored Procedures

This is a nice write up of how they work and when they will often be used.  Another situation is when you have a number of parameters that might be null in some circumstances, but have values in others.

http://forums.aspfree.com/t40921/s.html

posted @ Thursday, May 19, 2005 8:47 AM | Feedback (2)
ADO.NET PowerToys

http://adoguy.com/content.aspx?id=code/powertoys

posted @ Monday, May 16, 2005 9:50 AM | Feedback (2)
Using IFrame to 'eliminate' postbacks

There isn't a lot of technical data in this article, but it does describe a method where you can avoid visible postbacks when processing web forms:

http://aspadvice.com/message.aspx?MessageID=132959

posted @ Friday, May 13, 2005 3:14 PM | Feedback (2)
ASP.NET : Maintaining Scroll-Position on Postback

There are many ways to do this (the one I typically use is to set the focus on a page to the control I want), but here's a cool way to do it:

http://aspnet.4guysfromrolla.com/articles/111704-1.aspx

posted @ Friday, May 13, 2005 3:08 PM | Feedback (1)
Linked Server Syntax

An old article that references SQL Server 7 for its examples, but most of this should still work as is:

http://www.windowsitpro.com/windowsnt20002003faq/Article/ArticleID/14278/windowsnt20002003faq_14278.html

posted @ Thursday, May 12, 2005 9:53 AM | Feedback (1)
T-SQL: Can you alter multiple columns within a single alter table statement?

No.  You can add multiple columns, but you have to use a separate alter table statement for each column you want to alter.

posted @ Monday, May 09, 2005 1:55 PM | Feedback (85)
T-SQL : Using Triggers to Create Audit Trails

This article describes how to use triggers to create audit trails, using two scenarios:

1) A separate audit table is created for each table to be audited

2) A single audit table audits all tables

http://www.nigelrivett.net/Triggers_2_Creating_Audit_Trails.html

posted @ Monday, May 09, 2005 9:46 AM | Feedback (1)
T-SQL : Precision and Rounding

If you've ever wondered why “select 2/3” returns zero, here are two discussions that get into the reasons why:

http://www.windowsitpro.com/sqlserver/forums/messageview.cfm?catid=1690&threadid=128167&STARTPAGE=1

http://support.microsoft.com/kb/q42980/

BTW, “select cast(2 as dec (18,8))/cast(3 as dec (18,8)) “ will return the 'correct' result.

posted @ Monday, May 09, 2005 9:36 AM | Feedback (1)
Cannot add rows to sysdepends for the current stored procedure because it depends on the missing object

From:

http://web.gyrus.com/gyruskb/articles/04990841.htm

These warnings are normal and can be ignored. The reason they appear is because a script defines triggers or stored procedures that call stored procedures that have not been created yet. When the script is run, those stored procedures will be properly created and the references from the triggers or calling stored procedures to those stored procedure will be resolved.

 

posted @ Thursday, May 05, 2005 1:04 PM | Feedback (1)
T-SQL Get Date Part only from GetDate()

datediff(dd,0,@DateTime)

posted @ Tuesday, May 03, 2005 2:29 PM | Feedback (0)
T-SQL: Optional Parameters in SQL Server Search Queries

This looks like a cool way of handling this standard SQL need:

http://dotnetjunkies.com/WebLog/seichert/archive/2003/06/20/308.aspx

Another more in-depth discussion can be found at:

http://www.sommarskog.se/dyn-search.html

posted @ Tuesday, May 03, 2005 1:12 PM | Feedback (0)