What am I doing wrong here? I am trying to programmatcially run a report that
uses an Oracle stored procedure where the Oracle credentials would be
prompted if I ran interactively. The program (C#) compiles OK but I get an
'Object reference not set to an instance of an object' error when assigning
the credential property. The report runs interactively and I can
programmatically pass other parameters other than oracle credentials.
DataSourceCredentials[] credentials = new DataSourceCredentials[1];
credentials[0].DataSourceName = "MyDataSource";
credentials[0].UserName = "MyUser";
credentials[0].Password = "MyPassword";
data = _rs.Render("/MyFolder/MyReport","PDF", null, null, returnValues,
credentials , null, out encoding, out mimeType, out parametersUsed, out
warnings, out streamIds);
Any help appreciated.Sorry - just spotted it , I was missing a
credentials[0] = new DataSourceCredentials();
prior to assigning properties
"Joe" wrote:
> What am I doing wrong here? I am trying to programmatcially run a report that
> uses an Oracle stored procedure where the Oracle credentials would be
> prompted if I ran interactively. The program (C#) compiles OK but I get an
> 'Object reference not set to an instance of an object' error when assigning
> the credential property. The report runs interactively and I can
> programmatically pass other parameters other than oracle credentials.
> DataSourceCredentials[] credentials = new DataSourceCredentials[1];
> credentials[0].DataSourceName = "MyDataSource";
> credentials[0].UserName = "MyUser";
> credentials[0].Password = "MyPassword";
> data = _rs.Render("/MyFolder/MyReport","PDF", null, null, returnValues,
> credentials , null, out encoding, out mimeType, out parametersUsed, out
> warnings, out streamIds);
> Any help appreciated.
Wednesday, March 7, 2012
Programmatic Render of Reports into PDF format
Hi,
Can anybody please convert the following C# code into VB.Net Code.I tried
but its saying Object Reference not set to an instance of an object.
Or give me VB.NET(Web Application, CodeBehind:VB.Net) code to
programmatically render reports into PDF format.
// Prepare report parameter.
ParameterValue[] parameters = new ParameterValue[1];
parameters[0] = new ParameterValue();
parameters[0].Name = "Parameter1";
parameters[0].Value = Request.QueryString["id"];
Thanks
Rajesh YDim Parameters(1) As New ParameterValue
Parameters(0) = New ParameterValue
Parameters(0).Name = "Parameter1"
Parameters(0).Value = Request.QueryString("id")
"Rajesh Yennam" wrote:
> Hi,
> Can anybody please convert the following C# code into VB.Net Code.I tried
> but its saying Object Reference not set to an instance of an object.
> Or give me VB.NET(Web Application, CodeBehind:VB.Net) code to
> programmatically render reports into PDF format.
> // Prepare report parameter.
> ParameterValue[] parameters = new ParameterValue[1];
> parameters[0] = new ParameterValue();
> parameters[0].Name = "Parameter1";
> parameters[0].Value = Request.QueryString["id"];
> Thanks
> Rajesh Y|||Hi Rajesh:
I'd suspect the line of code :
parameters[0].Value = Request.QueryString["id"];
I'd guess you do not have an id parameter in the query string. Double
check the query string.
HTH,
--
Scott
http://www.OdeToCode.com/blogs/scott/
On Fri, 29 Oct 2004 03:43:01 -0700, "Rajesh Yennam"
<RajeshYennam@.discussions.microsoft.com> wrote:
>Hi,
>Can anybody please convert the following C# code into VB.Net Code.I tried
>but its saying Object Reference not set to an instance of an object.
>Or give me VB.NET(Web Application, CodeBehind:VB.Net) code to
>programmatically render reports into PDF format.
>// Prepare report parameter.
> ParameterValue[] parameters = new ParameterValue[1];
> parameters[0] = new ParameterValue();
> parameters[0].Name = "Parameter1";
> parameters[0].Value = Request.QueryString["id"];
>Thanks
>Rajesh Y
Can anybody please convert the following C# code into VB.Net Code.I tried
but its saying Object Reference not set to an instance of an object.
Or give me VB.NET(Web Application, CodeBehind:VB.Net) code to
programmatically render reports into PDF format.
// Prepare report parameter.
ParameterValue[] parameters = new ParameterValue[1];
parameters[0] = new ParameterValue();
parameters[0].Name = "Parameter1";
parameters[0].Value = Request.QueryString["id"];
Thanks
Rajesh YDim Parameters(1) As New ParameterValue
Parameters(0) = New ParameterValue
Parameters(0).Name = "Parameter1"
Parameters(0).Value = Request.QueryString("id")
"Rajesh Yennam" wrote:
> Hi,
> Can anybody please convert the following C# code into VB.Net Code.I tried
> but its saying Object Reference not set to an instance of an object.
> Or give me VB.NET(Web Application, CodeBehind:VB.Net) code to
> programmatically render reports into PDF format.
> // Prepare report parameter.
> ParameterValue[] parameters = new ParameterValue[1];
> parameters[0] = new ParameterValue();
> parameters[0].Name = "Parameter1";
> parameters[0].Value = Request.QueryString["id"];
> Thanks
> Rajesh Y|||Hi Rajesh:
I'd suspect the line of code :
parameters[0].Value = Request.QueryString["id"];
I'd guess you do not have an id parameter in the query string. Double
check the query string.
HTH,
--
Scott
http://www.OdeToCode.com/blogs/scott/
On Fri, 29 Oct 2004 03:43:01 -0700, "Rajesh Yennam"
<RajeshYennam@.discussions.microsoft.com> wrote:
>Hi,
>Can anybody please convert the following C# code into VB.Net Code.I tried
>but its saying Object Reference not set to an instance of an object.
>Or give me VB.NET(Web Application, CodeBehind:VB.Net) code to
>programmatically render reports into PDF format.
>// Prepare report parameter.
> ParameterValue[] parameters = new ParameterValue[1];
> parameters[0] = new ParameterValue();
> parameters[0].Name = "Parameter1";
> parameters[0].Value = Request.QueryString["id"];
>Thanks
>Rajesh Y
Programmatic logon to replication agent?
Greetings,
I have developed custom replication software that I have been running
in house for 2 years now. During replication operations I have been
SETting IDENT_INSERT OFF and then back ON again (after replication
completes). I have also been disabling and re-enabling my
CONSTRAINTS. I have since learned that it is better to use the "NOT
FOR REPLICATION" option in these cases to avoid the additional
overhead.
As I understand the "NOT FOR REPLICATION" option, it will do
everything that I want it to do during my replication process so long
as I have logged on as a replication agent.
1. What do I have to do in my custom program to authenticate it as a
replication agent? (My goal is for the NOT FOR REPLICATION settings
to "kick in" only during the scheduled execution of my program.) I am
coding in C# using .NET.
2. Will I have to somehow create a replication agent profile or is
there a default one that I can use?
3. Since my program runs all day in the background, will it be
necessary to "log off" as a replication agent during dormant periods?
(I don't want my program to interfere with the smooth runnings of
daily business operations occurring during normal business hours.)
I have spent much time looking for this answer both online and in the
SQL Server help. Your recommendation will be greatly appreciated.
Mario T. Lanza
Clarity Information Architecture, Inc.
2004.09
Mario,
if you use queued updating subscribers, the Identity (Yes, not for
replication) property is sent to the subscriber during the initial snapshot.
The insert stored procedure that the distribution agent uses is different to
the normal one, and at the start has the statement:
BEGIN
set identity insert "tablename" on
....
As you see, this is no different to what you are already using, and is not
inbuilt into the replication agent as such.
HTH,
Paul Ibison
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||I'm sorry but I am using a custom application that handles all aspects
of replication. It builds parameterized insert/update SQL
dynamically. Although I could set identity insert ON then OFF before
and after each row, I would rather do it before and after all the rows
of the table have been inserted/updated. The issue lies in the fact
that the application may be manually or abnormally terminated prior to
my clean up code.
One of the main things my clean up code does is:
1. Restores the identity insert to OFF
2. Restores all CHECK constraints
I have a CHECK constraint on each table which throws an exception if
the proposed identity value is outside of the assigned range at the
store location.
As such, I'm not sure you answered my question.
What do I do so that the "NOT FOR REPLICATION" settings are observed
only when my *custom* replication agent application is running.
Bear in mind I am not using anything provided by Microsoft for
replication.
Thanks.
Mario
|||Mario,
I was comparing your situation to transactional queued
updating subscribers. In this replication setup there is
no global identity insert setting for the agent - it is
set on an individual row insert, in the text of a stored
procedure. However, another poster has mentioned the same
thing in the context of merge replication, where the
agent itself appears to be able to make a global setting
of identity insert. He wanted to be able to execute his
code and 'pretend' to be the merge agent in order to take
advantage of tihs setting, but was unable to do so. Quite
how this is enabled is undocumented and not in the public
domain AFAIK.
Regards,
Paul Ibison
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||That's unfortunate. I was hoping that someone had overcome this issue.
In any case, thanks for responding. I appreciate your effort.
Mario
|||I had the same problem and could not find any solution. I finally found
a merge replication guru guy. He is actually a contractor in Toronto
and selling a special component which is totally able to pretend to be
merge agent.
It is simple to use but may be a little bit expensive for start-up
companies. Since we desperately needed that feature the company just
paid for it instead of digging for weeks over weeks.
It gets SQL Server credentials as class properties and you call
ExecuteSQL method, it executes it as if it is merge agent.
For example I can execute the following SQL against my DB using that
component:
INSERT myTable (IdentityField, column1, column2) VALUES (5, 'test',
test')
and it works!!
you do not need to say SET IDENTITY_INSERT ON/OFF or disable any
constraints.
If you need to contact that merge replication consultant just send me
an email.
Nury Sword
NurySword@.hotmail.com
MCSD - MCDBA
Toronto
I have developed custom replication software that I have been running
in house for 2 years now. During replication operations I have been
SETting IDENT_INSERT OFF and then back ON again (after replication
completes). I have also been disabling and re-enabling my
CONSTRAINTS. I have since learned that it is better to use the "NOT
FOR REPLICATION" option in these cases to avoid the additional
overhead.
As I understand the "NOT FOR REPLICATION" option, it will do
everything that I want it to do during my replication process so long
as I have logged on as a replication agent.
1. What do I have to do in my custom program to authenticate it as a
replication agent? (My goal is for the NOT FOR REPLICATION settings
to "kick in" only during the scheduled execution of my program.) I am
coding in C# using .NET.
2. Will I have to somehow create a replication agent profile or is
there a default one that I can use?
3. Since my program runs all day in the background, will it be
necessary to "log off" as a replication agent during dormant periods?
(I don't want my program to interfere with the smooth runnings of
daily business operations occurring during normal business hours.)
I have spent much time looking for this answer both online and in the
SQL Server help. Your recommendation will be greatly appreciated.
Mario T. Lanza
Clarity Information Architecture, Inc.
2004.09
Mario,
if you use queued updating subscribers, the Identity (Yes, not for
replication) property is sent to the subscriber during the initial snapshot.
The insert stored procedure that the distribution agent uses is different to
the normal one, and at the start has the statement:
BEGIN
set identity insert "tablename" on
....
As you see, this is no different to what you are already using, and is not
inbuilt into the replication agent as such.
HTH,
Paul Ibison
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||I'm sorry but I am using a custom application that handles all aspects
of replication. It builds parameterized insert/update SQL
dynamically. Although I could set identity insert ON then OFF before
and after each row, I would rather do it before and after all the rows
of the table have been inserted/updated. The issue lies in the fact
that the application may be manually or abnormally terminated prior to
my clean up code.
One of the main things my clean up code does is:
1. Restores the identity insert to OFF
2. Restores all CHECK constraints
I have a CHECK constraint on each table which throws an exception if
the proposed identity value is outside of the assigned range at the
store location.
As such, I'm not sure you answered my question.
What do I do so that the "NOT FOR REPLICATION" settings are observed
only when my *custom* replication agent application is running.
Bear in mind I am not using anything provided by Microsoft for
replication.
Thanks.
Mario
|||Mario,
I was comparing your situation to transactional queued
updating subscribers. In this replication setup there is
no global identity insert setting for the agent - it is
set on an individual row insert, in the text of a stored
procedure. However, another poster has mentioned the same
thing in the context of merge replication, where the
agent itself appears to be able to make a global setting
of identity insert. He wanted to be able to execute his
code and 'pretend' to be the merge agent in order to take
advantage of tihs setting, but was unable to do so. Quite
how this is enabled is undocumented and not in the public
domain AFAIK.
Regards,
Paul Ibison
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||That's unfortunate. I was hoping that someone had overcome this issue.
In any case, thanks for responding. I appreciate your effort.
Mario
|||I had the same problem and could not find any solution. I finally found
a merge replication guru guy. He is actually a contractor in Toronto
and selling a special component which is totally able to pretend to be
merge agent.
It is simple to use but may be a little bit expensive for start-up
companies. Since we desperately needed that feature the company just
paid for it instead of digging for weeks over weeks.
It gets SQL Server credentials as class properties and you call
ExecuteSQL method, it executes it as if it is merge agent.
For example I can execute the following SQL against my DB using that
component:
INSERT myTable (IdentityField, column1, column2) VALUES (5, 'test',
test')
and it works!!
you do not need to say SET IDENTITY_INSERT ON/OFF or disable any
constraints.
If you need to contact that merge replication consultant just send me
an email.
Nury Sword
NurySword@.hotmail.com
MCSD - MCDBA
Toronto
Programmatic killing connections
We want to create canned database restore jobs - possibly
as DTS packages.
We believe we need a way to find and kill database
connections, so that the actual restore can proceed.
Anyone done this ?
TIA
Hi Jim
Killing connections is one way. Another is to put the database into single
user mode, using the rollback immediate option, eg:
alter database [dbname] set single_user with rollback immediate
Check out ALTER DATABASE in Books Online for more info:
http://msdn.microsoft.com/library/en...aa-az_4e5h.asp
HTH
Regards,
Greg Linwood
SQL Server MVP
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message
news:ba1001c479c2$5c468bc0$a601280a@.phx.gbl...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA
|||I found a sample script to close all connections on:
http://khsw.blogspot.com/2004/08/sto...nnect-all.html
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message news:<ba1001c479c2$5c468bc0$a601280a@.phx.gbl>...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA
as DTS packages.
We believe we need a way to find and kill database
connections, so that the actual restore can proceed.
Anyone done this ?
TIA
Hi Jim
Killing connections is one way. Another is to put the database into single
user mode, using the rollback immediate option, eg:
alter database [dbname] set single_user with rollback immediate
Check out ALTER DATABASE in Books Online for more info:
http://msdn.microsoft.com/library/en...aa-az_4e5h.asp
HTH
Regards,
Greg Linwood
SQL Server MVP
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message
news:ba1001c479c2$5c468bc0$a601280a@.phx.gbl...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA
|||I found a sample script to close all connections on:
http://khsw.blogspot.com/2004/08/sto...nnect-all.html
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message news:<ba1001c479c2$5c468bc0$a601280a@.phx.gbl>...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA
Labels:
believe,
canned,
connections,
create,
database,
databaseconnections,
dts,
jobs,
kill,
killing,
microsoft,
mysql,
oracle,
packages,
possiblyas,
programmatic,
restore,
server,
sql
Programmatic killing connections
We want to create canned database restore jobs - possibly
as DTS packages.
We believe we need a way to find and kill database
connections, so that the actual restore can proceed.
Anyone done this ?
TIAHi Jim
Killing connections is one way. Another is to put the database into single
user mode, using the rollback immediate option, eg:
alter database [dbname] set single_user with rollback immediate
Check out ALTER DATABASE in Books Online for more info:
http://msdn.microsoft.com/library/e..._aa-az_4e5h.asp
HTH
Regards,
Greg Linwood
SQL Server MVP
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message
news:ba1001c479c2$5c468bc0$a601280a@.phx.gbl...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA|||I found a sample script to close all connections on:
http://khsw.blogspot.com/2004/08/st...onnect-all.html
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message news:<ba1001c479c2$5c468
bc0$a601280a@.phx.gbl>...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA
as DTS packages.
We believe we need a way to find and kill database
connections, so that the actual restore can proceed.
Anyone done this ?
TIAHi Jim
Killing connections is one way. Another is to put the database into single
user mode, using the rollback immediate option, eg:
alter database [dbname] set single_user with rollback immediate
Check out ALTER DATABASE in Books Online for more info:
http://msdn.microsoft.com/library/e..._aa-az_4e5h.asp
HTH
Regards,
Greg Linwood
SQL Server MVP
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message
news:ba1001c479c2$5c468bc0$a601280a@.phx.gbl...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA|||I found a sample script to close all connections on:
http://khsw.blogspot.com/2004/08/st...onnect-all.html
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message news:<ba1001c479c2$5c468
bc0$a601280a@.phx.gbl>...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA
Labels:
believe,
canned,
connections,
create,
database,
databaseconnections,
dts,
jobs,
kill,
killing,
microsoft,
mysql,
oracle,
packages,
possiblyas,
programmatic,
restore,
server,
sql
Programmatic killing connections
We want to create canned database restore jobs - possibly
as DTS packages.
We believe we need a way to find and kill database
connections, so that the actual restore can proceed.
Anyone done this ?
TIAHi Jim
Killing connections is one way. Another is to put the database into single
user mode, using the rollback immediate option, eg:
alter database [dbname] set single_user with rollback immediate
Check out ALTER DATABASE in Books Online for more info:
http://msdn.microsoft.com/library/en-us/tsqlref/ts_aa-az_4e5h.asp
HTH
Regards,
Greg Linwood
SQL Server MVP
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message
news:ba1001c479c2$5c468bc0$a601280a@.phx.gbl...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA|||I found a sample script to close all connections on:
http://khsw.blogspot.com/2004/08/stored-procedure-to-disconnect-all.html
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message news:<ba1001c479c2$5c468bc0$a601280a@.phx.gbl>...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA
as DTS packages.
We believe we need a way to find and kill database
connections, so that the actual restore can proceed.
Anyone done this ?
TIAHi Jim
Killing connections is one way. Another is to put the database into single
user mode, using the rollback immediate option, eg:
alter database [dbname] set single_user with rollback immediate
Check out ALTER DATABASE in Books Online for more info:
http://msdn.microsoft.com/library/en-us/tsqlref/ts_aa-az_4e5h.asp
HTH
Regards,
Greg Linwood
SQL Server MVP
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message
news:ba1001c479c2$5c468bc0$a601280a@.phx.gbl...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA|||I found a sample script to close all connections on:
http://khsw.blogspot.com/2004/08/stored-procedure-to-disconnect-all.html
"Jim Trowbridge" <jtrowbridge@.adelaidebank.com.au> wrote in message news:<ba1001c479c2$5c468bc0$a601280a@.phx.gbl>...
> We want to create canned database restore jobs - possibly
> as DTS packages.
> We believe we need a way to find and kill database
> connections, so that the actual restore can proceed.
> Anyone done this ?
> TIA
Saturday, February 25, 2012
Programmatic inspection of a dump?
I need to set up a job to allow users to restore their databases, on SQL Server 2000 SP3. The idea is that a user inserts a record into a table, identifying the dump they want to load. (They can only restore their own account.) A job picks up this record, restores the database, and notifies the user as appropriate.
My part of this is writing the procedure that the job executes, including the dump restore. Part of that is getting each dump's file groups (data, index, and log) into the proper locations for this server and this user.
Essentially, I need to be able to access the results of 'load filelistonly' from a cursor. How do I access the file list?Essentially, I need to be able to access the results of 'load filelistonly' from a cursor. How do I access the file list?
Google is your friend. http://www.karaszi.com/sqlserver/util_restore_all_in_file.asp|||Man .. its better if you do not call the backup a dump (You know what I mean !!!)... coz its what will save your A$$ when the database goes down ...
My part of this is writing the procedure that the job executes, including the dump restore. Part of that is getting each dump's file groups (data, index, and log) into the proper locations for this server and this user.
Essentially, I need to be able to access the results of 'load filelistonly' from a cursor. How do I access the file list?Essentially, I need to be able to access the results of 'load filelistonly' from a cursor. How do I access the file list?
Google is your friend. http://www.karaszi.com/sqlserver/util_restore_all_in_file.asp|||Man .. its better if you do not call the backup a dump (You know what I mean !!!)... coz its what will save your A$$ when the database goes down ...
Subscribe to:
Posts (Atom)