Showing posts with label reference. Show all posts
Showing posts with label reference. Show all posts

Tuesday, March 27, 2012

Bulk Load Text File Using Transact-SQL

I am a newbie (not a developer) trying to load reference tables with SQL script from text files. So far, I know I must use format files but the examples I get are not clear. I cannot find a simple syntax for the format file or the bulk load script. Please help!

Does the following topics help? BOL (SQL Server 2000 or 2005) has lot of examples including format files, statements to use etc.

http://msdn2.microsoft.com/en-us/library/ms189989.aspx

http://msdn2.microsoft.com/en-us/library/aa337544.aspx

http://msdn2.microsoft.com/en-us/library/ms175915.aspx

http://msdn2.microsoft.com/en-us/library/ms178129.aspx

http://msdn2.microsoft.com/en-us/library/ms189848.aspx

http://msdn2.microsoft.com/en-us/library/ms190625.aspx

sql

Friday, February 10, 2012

Build Parameter from C#/Custom Code

Hello,

Is it possible to add a multivalued parameter to a report from C#? I already have a C# .dll which I reference in the report. If so, could someone give some hints on how to do it?

As I searched the net for an answer to this, I came across ReportExecutionService. It looks like it's what I want, but I cant find the dll to reference in order to used this class. Does anyone know?

If it is not possible to do this from C#, then can someone please give an example on how to do it from Custom Code?

Thanks
/Peter

Hi,

The book SQL Reporting Services Step by Step Microsoft gave me most of my help,

Although, I'm trying to do a similar thing & am having a similar problem

I have a stored procedure which takes an array of values from the parameter list, but I want to process the value when the user clicks view report using the calculated parameter value not the actual parameter itself.

Code Snippet

CREATE PROCEDURE [dbo].[AStoredProc]
@.ArrayofValues ntext
AS

DECLARE @.DocHandle int

EXEC sp_xml_preparedocument @.DocHandle OUTPUT, @.ArrayofValues

SELECT
ColumnA, ColumnB

FROM
TableA
WHERE
ColumnA IN ( SELECT x.AnItem FROM OPENXML (@.DocHandle,N'/Root/SelectedItems,1)
WITH ( AnItem nvarchar(31)
) as x )

If I feed the parameter directly with XML eg.

In my custom code : The intention is to pass the array values via the parameter of a multi selected list which I've populated from a seperate query

eg so I have values AValue1 to AValuen in the list and I select from human readable form the parameter.

In my custom c# assembly I've created a public static function...

Code Snippet

public static string ConvertMultiParametersToXml(string ArrayofItems)
{
string retval = "";
const string rootNode = "Root";
const string ItemList = "SelectedItems";
const string Items= "AnItem";
XmlDocument xmlDoc = new XmlDocument();
XmlElement rootElement = xmlDoc.CreateElement(rootNode);
xmlDoc.AppendChild(rootElement);
string[] TheItemArray = ArrayofItems.Split(',');
for (int i = 0; i < TheItemArray .Length; i++)
{
XmlElement procElement = xmlDoc.CreateElement(ItemList);
procElement.SetAttribute(Items, TheItemArray [i].ToString());
rootElement.AppendChild(procElement);
// ProcArray[i]
}
retval = xmlDoc.InnerXml.ToString();
return retval;
}

Then after adding a reference, and inserting into a table I call

Code Snippet

=.ConvertMultiParametersToXml(Fields!ColumnA.Value)

but I get a dom error because when the report is processesed it uses the parameter value rather than the calculated value when processing the dataset.

Is there a way to stop the redirect the parameter value via code on the initial processing?

Kind Regards

Rich