myGoogleResults

Tuesday, January 22, 2008

SQL CLR

using System;
using System.Data;
using System.Data.SqlTypes;

public class MyCLRFunc
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString MyCLRHelloFunction()
{
return new SqlString("Hello everybody, I'm form SQLCLR!");
}
};



Create assembly MyUDFCLR from 'K:\Users\Sudesh\Desktop\MyCLRFunc.dll'

create function MyCLRHelloFunction()
Returns nvarchar(50)
External name MyUDFCLR.MyCLRFunc.MyCLRHelloFunction;
Go

select dbo.MyCLRHelloFunction()

Crystal Reports changing logon infomation

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

' this is the class for connecting crystal reports to database
' applies logoninfo

Public Class Creports

'returns a ReportDocument after applying logoninfo for the passed report
Public Function connect(ByVal rpt5 As ReportDocument) As ReportDocument

Dim tbCurrent As Table
Dim tbLogOnInfo As TableLogOnInfo

Try
'apply LogOn info for each table of the report document
For Each tbCurrent In rpt5.Database.Tables
tbLogOnInfo = tbCurrent.LogOnInfo

With tbLogOnInfo.ConnectionInfo
.ServerName = mod_1.serverName
.UserID = mod_1.userName
.Password = mod_1.password
.DatabaseName = mod_1.dataBaseName
End With

tbCurrent.ApplyLogOnInfo(tbLogOnInfo)
'tbLogOnInfo = tbCurrent.LogOnInfo
'tbLogOnInfo.ConnectionInfo.ServerName = serverName
'tbLogOnInfo.ConnectionInfo.UserID = userName
'tbLogOnInfo.ConnectionInfo.Password = password
'tbLogOnInfo.ConnectionInfo.DatabaseName = databaseName
'tbCurrent.ApplyLogOnInfo(tbLogOnInfo)
Next tbCurrent

Return rpt5

Catch lsExp As LoadSaveReportException
MessageBox.Show(lsExp.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

End Function

End Class