Thursday, October 9, 2008

Conditional Background color for Text box

1.  Background color based on the value of the input parameter
 
        =iif(Fields!TextBox1.Value = Parameters!ParameterName.Label,"LightGrey","DarkGrey")  1.  Background color based on the value of the input parameter

2.   Background color based on a condition

       =iif(Fields!TextBox1.Value > 10,"LightGrey","DarkGrey")

3.   Background color on alternating row

       =iif(RunningValue(Fields!FieldName1.Value,COUNTDISTINCT,NOTHING) MOD 2 = 0,"LightGrey","DarkGrey")

 

Friday, September 5, 2008

Multiple lines in a text box

Sometimes we might need to present data in a text box in multiple lines. The newline character used for this purpose is VbCrLf

ex
="Hello" & VbCrLf & "World"

will be
Hello
World

Friday, March 14, 2008

error: 26 - Error Locating Server/Instance Specified

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. "

           Programmers often get this error message when connecting to a SQL Server named instance.  Every time a client connects to the SQL Server named instance, an SSRP UDP packet is sent to the server machine UDP port 1434. This is done to know the configuration information of the SQL instance, e.g., protocols enabled, TCP port, pipe name etc. 

Without these information, the client does not know how to connect to the server and it fails with the above error message.
Make a checklist of the following

1. Check your server name is correct (typo).
  •  Check to see the instance name is correct and and running
  •   Check the server DNS (ping the server).
2. Check to ensure  your database engine is configured to accept remote connections.
  •  Go to Start  -> All Programs ->  SQL Server 2005 ->  Configuration Tools ->  SQL Server  Surface  Area Configuration     
  •  Click on Surface Area Configuration for Services and Connections
  •  Select the named instance   -> Database Engine  ->  Remote Connections
  •  Click  Enable local and remote connections
  •   Restart the server
3.Check the Connection string. If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings     (machineName\Named Instance)

4.If firewall is enabled on the server make an exception  for the SQL Server instance and port
  •   Go to   Start  -> Run -> Firewall.cpl
  •   Click on exceptions tab
  •   Add the sqlservr.exe  and the default  port (1433)
5. Check the SQL Browser service is running on the server, if firewall is on make an exception for the SQL Browser.exe   and/or UDP port 1434 .



Saturday, February 9, 2008

Dropping all tables in the current database

WHILE EXISTS(SELECT [name] FROM sys.tables WHERE [type] = 'U')
BEGIN
DECLARE @table_name varchar(50)
DECLARE table_cursor CURSOR FOR SELECT [name] FROM sys.tables WHERE [type] = 'U'
OPEN table_cursor
FETCH NEXT FROM table_cursor INTO @table_name
WHILE @@FETCH_STATUS = 0
BEGIN
BEGIN TRY
EXEC ('DROP TABLE [' + @table_name + ']')
PRINT 'Dropped Table ' + @table_name
END TRY
BEGIN CATCH
END CATCH
FETCH NEXT FROM table_cursor INTO @table_name
END
CLOSE table_cursor
DEALLOCATE table_cursor
END