Friday, February 22, 2013

Identify Column Name in SQL

SELECT sc.[name] AS column_name ,so.[name]  FROM syscolumns sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.[name] = 'Landtype'
AND so.xtype = 'U'
ORDER BY so.name

Identify text in stored procedure in SQL

SELECT Name FROM sys.procedure WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE %landtype% 
SELECT DISTINCT so.name FROM syscomments sc INNER JOIN sysobjects so ON sc.id=so.id WHERE
 sc.TEXT LIKE '%landtype%'

SELECT * FROM  sys.sysobjects WHERE id in (
select id from sys.syscomments where text like '%landtype%')
 
 

 
 

GDI and USER Objects Dispose Closing Form

In windows application GDI and User Object  Exceeds limit if we dont remove the Objects after close form.

Solution:
During form close Collect GC and wait for till process complete will release the GDI and User Object if it is not disposed properly.

Code:
GC.Collect();GC.WaitForPendingFinalizers();
Export Connection string to  Excel sheet Data Connection properities in C#

this.wb.Connections["ExcelData"].OLEDBConnection.Connection=ConnectionString;
this.wb.Connections["ExcelData"].OLEDBConnection.Connection=CommandText;
this.wb.Connections["ExcelData"].OLEDBConnection.BackgroundQuery = false;this.wb.Connections["ExcelData"].OLEDBConnection.Refresh();


Connectionstring =
'OLEDB;Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=DBName;Data Source=ServerInstanceName;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=MANOJKUMARP;Use Encryption for Data=False;Tag with column collation when possible=False'  CommandText ='Select * from tableName'