Showing posts with label net. Show all posts
Showing posts with label net. Show all posts

Thursday, March 29, 2012

Error when trying to save report in pdf

I developed a report using sql server reporting services and the vs.net
designer. Then I wrote another class that downloads the result into
pdf and excel formats. When I run the program, the excel file opens
fine but the pdf says "there was an error opening this document. the
file is damaged and cannot be repaired". I have seen other forums with
the same issue and microsoft is yet to provide an answer to this
problem. Can someone help please? Any suggestions are well appreciated.
Thanks.There are a variety of reasons this could happen. I'd start by first
looking at the Report Server log file and see what exception (if any) occurs
when you render to PDF. Secondly, I'd dump the PDF into notepad and see if
there are any errors embedded at the end of the stream.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
<csuman@.gmail.com> wrote in message
news:1130708307.146769.204230@.g49g2000cwa.googlegroups.com...
>I developed a report using sql server reporting services and the vs.net
> designer. Then I wrote another class that downloads the result into
> pdf and excel formats. When I run the program, the excel file opens
> fine but the pdf says "there was an error opening this document. the
> file is damaged and cannot be repaired". I have seen other forums with
> the same issue and microsoft is yet to provide an answer to this
> problem. Can someone help please? Any suggestions are well appreciated.
> Thanks.
>|||I am having the same problem - just upgraded Adobe Reader to 7.0.5.
Looking at the pdf created in NotePad: Starts with
%PDF-1.3%
1 0 obj [/PDF /Text /ImageB /ImageC /ImageI] . . . has a bunch of stuff . . .
"ends" trailer << /Size 10 /Root 8 0 R/Info 9 0 R >>
startxref
3893
%%EOF
then after the EOF is a full dump of the HTML code:
%%EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title> . . .
I've asked the database manager to look at the reporting services logs but
if this gives anyone a clue to the cause/solution . . .
--
gwf
"Donovan Smith [MSFT]" wrote:
> There are a variety of reasons this could happen. I'd start by first
> looking at the Report Server log file and see what exception (if any) occurs
> when you render to PDF. Secondly, I'd dump the PDF into notepad and see if
> there are any errors embedded at the end of the stream.
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> <csuman@.gmail.com> wrote in message
> news:1130708307.146769.204230@.g49g2000cwa.googlegroups.com...
> >I developed a report using sql server reporting services and the vs.net
> > designer. Then I wrote another class that downloads the result into
> > pdf and excel formats. When I run the program, the excel file opens
> > fine but the pdf says "there was an error opening this document. the
> > file is damaged and cannot be repaired". I have seen other forums with
> > the same issue and microsoft is yet to provide an answer to this
> > problem. Can someone help please? Any suggestions are well appreciated.
> >
> > Thanks.
> >
>
>sql

Error when trying to execute a job from windows service.

Hi,
I'm trying to execute a DTS package from a .NET service. The service is
running under a domain account that owns the job which it executes using
'sp_start_job'. The call to the sp succeeds however checking the Job history
gives: -
"The job failed. Unable to determine if the owner (DOMAIN\ServiceUser) of
job <JobName> has server access (reason: Could not obtain information about
Windows NT group/user 'DOMAIN\ServiceUser'. [SQLSTATE 42000] (Error 8198
))."
SQL Server 2000 SP4
Both SQLServer + SQLAgent run under a domain account (different to the
service)
ServiceUser has login to sql server not an admin, however I've tried using
the SQL Agent Proxy account still no success.
Any ideas?
thanks Paul> SQL Server 2000 SP4
> Both SQLServer + SQLAgent run under a domain account (different to the
> service)
> ServiceUser has login to sql server not an admin, however I've tried using
> the SQL Agent Proxy account still no success.
The SQL 2000 Books Online <instsql.chm::/in_overview_6k1f.htm> states that
the SQL Agent service account must be a member of the local Administrators
group in order to "Create CmdExec and ActiveScript jobs belonging to someone
other than a SQL Server administrator".
Hope this helps.
Dan Guzman
SQL Server MVP
"Paul Coulson" <nospam@.nospam.net> wrote in message
news:OZUDQ3WOGHA.3144@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I'm trying to execute a DTS package from a .NET service. The service is
> running under a domain account that owns the job which it executes using
> 'sp_start_job'. The call to the sp succeeds however checking the Job
> history gives: -
> "The job failed. Unable to determine if the owner (DOMAIN\ServiceUser) of
> job <JobName> has server access (reason: Could not obtain information
> about Windows NT group/user 'DOMAIN\ServiceUser'. [SQLSTATE 42000] (Er
ror
> 8198))."
> SQL Server 2000 SP4
> Both SQLServer + SQLAgent run under a domain account (different to the
> service)
> ServiceUser has login to sql server not an admin, however I've tried using
> the SQL Agent Proxy account still no success.
> Any ideas?
> thanks Paul
>|||Hi Dan,
Thanks that's sorted it. Also got it working using the proxy account
again this needed local admin rights.
Cheers Paul
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:ueU6PriOGHA.1192@.TK2MSFTNGP11.phx.gbl...
> The SQL 2000 Books Online <instsql.chm::/in_overview_6k1f.htm> states that
> the SQL Agent service account must be a member of the local Administrators
> group in order to "Create CmdExec and ActiveScript jobs belonging to
> someone other than a SQL Server administrator".
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Paul Coulson" <nospam@.nospam.net> wrote in message
> news:OZUDQ3WOGHA.3144@.TK2MSFTNGP11.phx.gbl...
>|||I'm glad you were able to get it working. However, I'd be leery about
granting admin rights the proxy account since that allows non-sysadmins to
run processes with admin rights. Now that you got the service accounts
sorted out, I would expect your DTS package to run fine as long as the proxy
account has permissions on data and files accessed by the package.
Hope this helps.
Dan Guzman
SQL Server MVP
"Paul Coulson" <nospam@.nospam.net> wrote in message
news:eCdaOR4OGHA.812@.TK2MSFTNGP10.phx.gbl...
> Hi Dan,
> Thanks that's sorted it. Also got it working using the proxy account
> again this needed local admin rights.
> Cheers Paul
>
>
> "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
> news:ueU6PriOGHA.1192@.TK2MSFTNGP11.phx.gbl...
>

Wednesday, March 7, 2012

Error Using ODP.NET


Hi ,
I am trying to connect to ORacle using ODP.NET. I am getting an "Object
must implement IConvertible" error.
I researched this issue online and it seems it maybe mis matched data
types in the parameters collection, however i have varchar2 in the
oracle proc and OracleType.Varchar in my code.(I am trying to use the
OracleHelper class, this logic worked with OleDB).
OracleParameter[] parameters =
{
new OracleParameter("p_Number", OracleType.VarChar),
new OracleParameter("p_Name",OracleType.VarChar),};
parameters[0].Value = "111";
parameters[1].Value = "guest";
OracleHelper. ExecuteNonQuery(connectionstring,procNam
e, parameters);
Please help !
- Arthur
*** Sent via Developersdex http://www.examnotes.net ***Never mind, I used another overload and made it work
(for anyone interested)
OracleHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, procName,
parameters);
Arthur
*** Sent via Developersdex http://www.examnotes.net ***

Friday, February 24, 2012

Error treatment

Hi,
I'm trying to find the best way to treat erro in my web applicatin (using VB.NET) but i'm something is not right.
Look at this code (part of the code was removed but on the original, we do need a transaction because we update different tables):

Protected Sub ClearFlag()Dim mySQLConnectionAs New SqlConnection(ConfigurationManager.ConnectionStrings("MyString").ToString)Dim mySQLTransactionAs SqlTransactionDim mySQLCommandAs SqlCommandDim sQuery1As String ="UPDATE Users SET UserStatus = 1"Try mySQLConnection.Open() mySQLTransaction = mySQLConnection.BeginTransaction mySQLCommand =New SqlCommand(sQuery1, mySQLConnection, mySQLTransaction) mySQLCommand.ExecuteNonQuery() mySQLTransaction.Commit()Catch exAs Exception mySQLTransaction.Rollback()Finally mySQLConnection.Close() mySQLCommand.Dispose() mySQLTransaction.Dispose() mySQLConnection.Dispose()End Try End Sub

The Error List says:

- Variable 'mySQLCommand' is used before it has been assigned a value. A null reference exception could result at runtime.
- Variable 'mySQLTransaction' is used before it has been assigned a value. A null reference exception could result at runtime.

What i did to try to avoid it is declare the variables using "NEW", like:

Dim mySQLCommand as NEW SQLCommand

But, i can't do this with the transaction.

NESTED TRY AND CATCH

Also, i was thinking about this to handle specific errors like, try to open a connection and just continue if the connection was oppened, or else, treat that error. Try to update the database and just continue, it if did well or else, treat the error...

Is that possible to use nested try and catch for this or, does anyone has a better idea?
I appreciate any comment.

Thanks

Hi E.Brito,

As I can see, these messages are warning messages. The comipler analyzes the code and found the variable might not be pointing to a valid object, since the Try block and Final Block are in same level.

Of course, you can ignore this message, but I would suggest you put the following code before the Try block.

mySQLConnection.Open()
mySQLTransaction = mySQLConnection.BeginTransaction

mySQLCommand = New SqlCommand(sQuery1, mySQLConnection, mySQLTransaction)

This will eliminate the warning message.

HTH. If anything is unclear, please feel free to mark this post as Not Answered and post your reply. Thanks!

|||

hiKevin Yu

Thanks for your replay.
If i do it the warning message will desapear but... what if i get an error on the connection? Since it will be out of the "Try Catch" block, i wont be able to handle the error.
Do you have a sugestion for this?

Thanks in advance,

|||

Hi E.Brito,

For this warning message, you can try to put the dispost in an If block, like

If Not mySQLCommand Is Nothing Then mySQLCommand.Dispose()

This will make sure that the object reference is not Nothing, but it will not deliminate the warning message. In this case, you can ignore it.

You can also put the SqlConnection.Open in another try/catch block, so that you can seperate the process of exceptions.

|||This will work fine.
Thanks a lot for your help

Wednesday, February 15, 2012

error running sp_stored_procedures

I downloaded the code example "Running Stored Procedures with ASP.NET" (http://www.dotnetjunkies.com/Tutorial/9AE62C44-3841-4687-B906-2F6D4A5A4622.dcik)
and I'm having trouble filtering the sp's that are populating the drop down box. Here's my code: (all I did was add the one parameter)

Dim ds As New DataSet

Dim conn As New SqlConnection( _
Data source=" & DatabaseServer.Text & _
";User id=" & Userid.text & _
";Password=" & Password.Text & _
";Initial catalog=" & Database.Text)

Dim cmd As New SqlCommand("sp_stored_procedures", conn)
Dim adpt As New SqlDataAdapter(cmd)
Try
cmd.Parameters.Add("@.sp_name", SqlDbType.NVarchar, 390).Value = CType("my%", String)

so if I comment out the cmd.Parameters.Add ... line it all works fine and I get every sp, but if I uncomment it I get " Incorrect syntax near 'sp_stored_procedures'" every time no matter what i put in the string.

I have a feeling I'm doing something stupid :) Anyone have any ideas? The query works fine in query analyzer with the same arguments that I'm trying in the code.Add:

cmd.CommandType=CommandType.StoredProcedure|||...and you shouldn't begin the name of your stored procedures with the sp_ prefix. This prefix should always be reserved only for system stored procedures.|||"
...and you shouldn't begin the name of your stored procedures with the sp_ prefix. This prefix should always be reserved only for system stored procedures.

"

It IS a system stored procedure.|||"
Add:

cmd.CommandType=CommandType.StoredProcedure
"

Doh!

Thanks!