Tuesday, March 27, 2012
Calling store procedure in Report throu VB
How to call store procedure in Crystal Report through VISUAL BASIC. i have Sp which has 3 parameters one is string others are dates parameter ,
how to to in the visual basic coding.
can any one help me passing paramerters .
Thanks
AnnuFor Vb 6:
Get rs (Recordset) calling stored procedure with parameters
After:
Dim report As CRAXDRT.report
Set report = crystal.OpenReport(App.Path & _
IIf(Right(App.Path, 1) = "\", "", "\") & _
s_Rpt & GetAdditionalNamePart(s_Rpt) & ".rpt") 'OPEN REPORT
report.Database.LogOnServerEx _
"crdb_odbc.dll", _
c_Settings.GetVal(CRYSTALDSN), _
c_Settings.GetVal(DBNAME), _
c_User.Name, _
c_User.Password, , _
c_Db.ConnectionStr
report.DiscardSavedData 'CLEARS REPORT SO WE WORK FROM RECORDSET
report.Database.SetDataSource rs 'LINK REPORT TO RECORDSET
Load frmReport
'ShowSendButton s_Rpt, frmReport.crV, frmReport.cmdSend
'crV - crystal viewer control
frmReport.crV.ReportSource = report 'LINK VIEWER TO REPORT
frmReport.crV.ViewReport
Best,
ika|||This is using VB 6 and CR 8.5 with RDC...
You can get your data from the Stored Proc through ADO and then pass the ADO recordset to Crystal:
'dsrReport is the name of your dsr file
Dim Report As New dsrReport
Set cmdData = New ADODB.Command
Set rsData = New ADODB.Recordset
cmdData.ActiveConnection = cnConnection
cmdData.CommandText = "sp_StoredProcName"
cmdData.CommandType = adCmdStoredProc
cmdData.Parameters.Refresh
cmdData.Parameters("@.Param1") = strParam1
cmdData.Parameters("@.Param2") = dtmParam2
cmdData.Parameters("@.Param3") = dtmParam3
'Required for RecordCount to return an accurate count
rsData.CursorType = adOpenDynamic
rsData.CursorLocation = adUseClient
rsData.Open cmdData
If Not rsData.EOF Then
Report.DiscardSavedData
Report.Database.SetDataSource rsData, 3, 1
End Ifsql
Sunday, March 25, 2012
Calling SQL editor dialog from application
This is not for the end user but as a developer tool for those who have a copy of Visual Studio. I would like to be able to visually design the SQL commands we are storing in a database.
Thanks, Dave C.
Hi Dave,
There is no direct way to launch the SQL Query editor based on a string in your application. The best you can do is save the string to a file and then use the command line parameters for loading that file into SSMS using SQLWB.EXE.
Thank you,
Bill Ramos, PM, SSMS
Tuesday, March 20, 2012
Calling DTS package from VB/Ms-Access 2000
My name is kanishk. I am facing some issue in calling the DTS package from Visual Basic code.
The brief history of issue is :
We have a application which uses Ms-Access as front end and MS-Sql server 2000 as backend. Perviously we has MS-Access 97 version and MS-Sql 2000 .In this comination the DTS package was working fine.
Now We have changes the fornt end to MS-Access 2002. Here the DTS package is not working .
Can you please help me out to get the proper syntax to call the DTS package from VB code.What's your current syntax and what SP you have on the server?|||The DTS package is called from VB code. There is no SP at server side for DTS calling.
The Syntax in MS-Access(VB code )in version 97 is :
Sub RunDTS(strServer As String, strUser As String, strPassword As String, strDTS As String)
Dim dtsp As New DTS.Package
dtsp.LoadFromSQLServer _
ServerName:=strServer, _
ServerUserName:=strUser, _
ServerPassword:=strPassword, _
PackageName:=strDTS
dtsp.Execute
DoEvents
End Sub|||First make sure you have : Microsoft Dtspackage Object library activated in visual basic references.
Here is a visual basic code template :
Dim cn as ADODB.connection
Dim oPKG As DTS.Package
dim i as integer
SET cn = currentproject.connection
Set oPKG = New DTS.Package
if cn.Properties("Integrated Security") <> "SSPI" Then
'oPKG.LoadFromSQLServer cn.Properties("Data Source"), cn.Properties("USER ID"), cn.Properties("PASSWORD"), DTSSQLStgFlag_Default, , , , "DtsName"
Else
'oPKG.LoadFromSQLServer cn.Properties("Data Source"), ,, DTSSQLStgFlag_UseTrustedConnection, , , , "DtsName"
End If
On oPKG.FailOnError GoTo HandleErr
' -------- Facultatif , Use only in case you want to determine source file location at runtime
i = 1
For i = 1 To oPKG2.Connections.Count
FileSourceName = oPKG.Connections.Item(i).DataSource
oPKG.Connections.Item(i).DataSource = Me.FileLocation '( source file full name )
Next i
' -------
oPKG.Execute
oPKG.UnInitialize
Set oPKG = Nothing
ExitHere:
Exit Sub
HandleErr:
MsgBox "Error " & Err.Number & vbCrLf & vbLf & Err.Source & vbCrLf & vbLf & Err.Description, vbCritical
Resume ExitHere
Calling debugger from SSMS
I realize that the DEBUG capability has been removed from SSMS and moved to the IDe for Visual Studio. As much as that annoys me , I am dealing with it.
Is there a way I can open a SP into the debugger from SSMS? I very much miss the ability to right click a SP in my list of 300 and choose form edit, run or debug. I dont care if hte debugger is a separate app, can't I have SSMS send my proc to the visual studio debugger?
Currently I have to open the VS app separately, and then establish connection, and the re-fnd my proc in that very long list of 300 that is in there.
Sorry, you need to use Visual Studio to debug stored procedures in SQL Server.|||I know that.
The question more specifically is:
Is there a way to link the SSMS annd hte visual studio together such that I can tell visual studio to debug a SP I am pointing to in the SSMS?
I want to be able to right click a Sproc in SSMS, select "Step Into" and have the Visual studio open on its own with the correct SP in debug mode.
|||No this is not possible.|||Hi,
I tried to configure t-sql debugger in my visual studio 2005. I have sql server 2005. I somehow unable to debug the stored procedure thru my server explorer in VS 2005. I can put a breakpt, but never be able to hit the brk point kept in stored procedure.
Please help me out to start t-sql debugging in my vs 2005.
Thanks,
Anni
Calling debugger from SSMS
I realize that the DEBUG capability has been removed from SSMS and moved to the IDe for Visual Studio. As much as that annoys me , I am dealing with it.
Is there a way I can open a SP into the debugger from SSMS? I very much miss the ability to right click a SP in my list of 300 and choose form edit, run or debug. I dont care if hte debugger is a separate app, can't I have SSMS send my proc to the visual studio debugger?
Currently I have to open the VS app separately, and then establish connection, and the re-fnd my proc in that very long list of 300 that is in there.
Sorry, you need to use Visual Studio to debug stored procedures in SQL Server.|||I know that.
The question more specifically is:
Is there a way to link the SSMS annd hte visual studio together such that I can tell visual studio to debug a SP I am pointing to in the SSMS?
I want to be able to right click a Sproc in SSMS, select "Step Into" and have the Visual studio open on its own with the correct SP in debug mode.
|||No this is not possible.|||Hi,
I tried to configure t-sql debugger in my visual studio 2005. I have sql server 2005. I somehow unable to debug the stored procedure thru my server explorer in VS 2005. I can put a breakpt, but never be able to hit the brk point kept in stored procedure.
Please help me out to start t-sql debugging in my vs 2005.
Thanks,
Anni