Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Friday, February 24, 2012

C# render method error - invalid arguements

I have the following c# code for rendering reports. The VB equivilant
works perfect but this example bombs on the render method:
ReportingService rs = new ReportingService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
DataSourceCredentials[] credentials = null;
byte[] result = null;
string reportPath = "/Capital Request/Request";
string historyID = null;
string format = "PDF";
string devInfo = "<DeviceInfo><HTMLFragment>false</HTMLFragment><Zoom>100</Zoom><Toolbar>FALSE</Toolbar></DeviceInfo>";
string showHideToggle = null;
string encoding;
string mimeType;
Warning[] warnings = null;
ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
SessionHeader sh = new SessionHeader();
rs.SessionHeaderValue = sh;
try
{
result = rs.Render(reportPath, format, historyID,
devInfo, parameters, credentials,
showHideToggle, out encoding, out mimeType,
out reportHistoryParameters, out warnings,
out streamIDs);
sh.SessionId = rs.SessionHeaderValue.SessionId;
}
The error is as follows:
CS1502: The best overloaded method match for
'RSProxy.ReportingService.Render(string, string, string, string,
RSProxy.ParameterValue[], RSProxy.DataSourceCredentials[], string, ref
string, ref string, ref RSProxy.ParameterValue[], ref
RSProxy.Warning[], ref string[])' has some invalid arguments
I have tried everything. Any help is appreciated.use the ref keyword in place of the out keyword.
"Stephen" <switter@.enpathmed.com> wrote in message
news:1104010447.834507.213950@.c13g2000cwb.googlegroups.com...
> I have the following c# code for rendering reports. The VB equivilant
> works perfect but this example bombs on the render method:
> ReportingService rs = new ReportingService();
> rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
> DataSourceCredentials[] credentials = null;
> byte[] result = null;
> string reportPath = "/Capital Request/Request";
> string historyID = null;
> string format = "PDF";
> string devInfo =>
"<DeviceInfo><HTMLFragment>false</HTMLFragment><Zoom>100</Zoom><Toolbar>FALS
E</Toolbar></DeviceInfo>";
> string showHideToggle = null;
> string encoding;
> string mimeType;
> Warning[] warnings = null;
> ParameterValue[] reportHistoryParameters = null;
> string[] streamIDs = null;
> SessionHeader sh = new SessionHeader();
> rs.SessionHeaderValue = sh;
> try
> {
> result = rs.Render(reportPath, format, historyID,
> devInfo, parameters, credentials,
> showHideToggle, out encoding, out mimeType,
> out reportHistoryParameters, out warnings,
> out streamIDs);
> sh.SessionId = rs.SessionHeaderValue.SessionId;
> }
> The error is as follows:
> CS1502: The best overloaded method match for
> 'RSProxy.ReportingService.Render(string, string, string, string,
> RSProxy.ParameterValue[], RSProxy.DataSourceCredentials[], string, ref
> string, ref string, ref RSProxy.ParameterValue[], ref
> RSProxy.Warning[], ref string[])' has some invalid arguments
> I have tried everything. Any help is appreciated.
>|||That was it! At least in part. The only other thing is the encoding
and mimetype variables were not set:
string showHideToggle = null;
string encoding;
string mimeType;
I got an unassigned variable error so I did the following:
string showHideToggle = null;
string encoding=null;
string mimeType=null;
and it worked. This example came straight out of BOL. Seems there is
a problem with the example. Thats for correcting that for me. I
really appreciate it as I have been working on this for about two
weeks.
Tim Ellison wrote:
> use the ref keyword in place of the out keyword.
> "Stephen" <switter@.enpathmed.com> wrote in message
> news:1104010447.834507.213950@.c13g2000cwb.googlegroups.com...
> > I have the following c# code for rendering reports. The VB
equivilant
> > works perfect but this example bombs on the render method:
> >
> > ReportingService rs = new ReportingService();
> > rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
> > DataSourceCredentials[] credentials = null;
> >
> > byte[] result = null;
> > string reportPath = "/Capital Request/Request";
> > string historyID = null;
> > string format = "PDF";
> > string devInfo => >
>
"<DeviceInfo><HTMLFragment>false</HTMLFragment><Zoom>100</Zoom><Toolbar>FALS
> E</Toolbar></DeviceInfo>";
> > string showHideToggle = null;
> > string encoding;
> > string mimeType;
> > Warning[] warnings = null;
> > ParameterValue[] reportHistoryParameters = null;
> > string[] streamIDs = null;
> > SessionHeader sh = new SessionHeader();
> > rs.SessionHeaderValue = sh;
> >
> > try
> > {
> > result = rs.Render(reportPath, format, historyID,
> > devInfo, parameters, credentials,
> > showHideToggle, out encoding, out mimeType,
> > out reportHistoryParameters, out warnings,
> > out streamIDs);
> > sh.SessionId = rs.SessionHeaderValue.SessionId;
> > }
> >
> > The error is as follows:
> >
> > CS1502: The best overloaded method match for
> > 'RSProxy.ReportingService.Render(string, string, string, string,
> > RSProxy.ParameterValue[], RSProxy.DataSourceCredentials[], string,
ref
> > string, ref string, ref RSProxy.ParameterValue[], ref
> > RSProxy.Warning[], ref string[])' has some invalid arguments
> > I have tried everything. Any help is appreciated.
> >

Sunday, February 19, 2012

C# application - method to import delimeted CSV to sql server table

Hi,

I'm writing a telecom billing system where it is necessary to import csv delimited files into a sql server table.

1) The csv files to import differ in column arrangement i.e SQL server table arrangement = A, B, C, D whilst CDR = - , A, -, C, D

2) The csv files are delimited via different characters i.e some are del.. by commas some by semi colons

I can import a CSV file from my application using a BULK INSERT query but only using CSV that resembles the structure of the table exactly

How can I pass a CSV to the table and state where I want each CSV column to fill a column in the SQL SERVER table

Below is how I am managing to pass a CDR to the SQL table that I have pre manufactured to resemble the structure of the SQL table Is there a way I can state which values from the CSV I want to pass to corresponding columns in the SQL table:

string conString =@."Provider=SQLOLEDB;Server=(local);Database=Billing;Uid=sa;Pwd=sa;";

for (int i = listBox1.Items.Count - 1; i >= 0; i--)

{

string strSQL;

OleDbConnection objConnection =null;

OleDbCommand objCmd =null;

objConnection =newOleDbConnection(conString);

string cdr = listBox1.GetItemText(listBox1.Items[i]);

strSQL ="BULK INSERT Campaign FROM '"+ cdr +"' WITH (FIELDTERMINATOR = ',', ROWTERMINATOR = '\n')";

OleDbDataReader objDataReader;

try

{

objConnection.Open();

objCmd =

newOleDbCommand(strSQL, objConnection);

objCmd.ExecuteNonQuery();

objCmd =

null;

objDataReader =

null;

objConnection.Close();

listBox1.Items.Remove(listBox1.Items[i]);

}

catch (Exception ex)

{

objConnection.Close();

}

objCmd =

null;

objConnection =

null;

}

Regards

Simon

It is not practical to use ExecuteNonQuery to import a CVS file because the data needs to be cleaned before insert so try the link below for a step by step guide to import the data into SQL Server. The reason it is failing is you are sending ADO.NET a data access component to perform ETL(extraction transformation and loading) task. Hope this helps.

http://www.databasejournal.com/features/mssql/article.php/3580216

|||

the code works but only for csv that mirrors the table in structure, I want to create a query that picks certain columns from the csv parses them and pastes them into a table

regards

Simon

|||

If the columns are the same that is a standard insert, picking columns is again ETL, try the CVS parser from the link below and ADO.NET is not used. Hope this helps.

http://www.heikniemi.net/hc/archives/000152.html

|||

I'll give it a go and get back to you seems a good way around it. Can I use it to iterate over each seperate line and load the values i need into a temporary dataset I.e containing a pseudo table mirroring that in sql server

Simon

Tuesday, February 14, 2012

Business Rules Table

Which is the best practice for Business Rules

a. Hardcoded Column Names

b. Rowwise values RuleName, Criteria

Please suggest the best method

That depends upon your implementation of the Business Rules, there is no rule of thumb for it. Do you implement the rules in the logic of SQL Server or your middle-tier ? Which approach did you use to validate the rules ?

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||we implement the rules in the middle tier

|||

It always better to use the Business Rules on the Middle Tier. That’s what all the Middle Tier apps says, don't use your middle tier as a wrapper of your SP, get the data and do it on middle tier.

It might be very easy to maintain & easy to implement. You can utilize all the language features while do this. But, DB sometimes you have to stay on the fixed boundary & limitations.