Showing posts with label idea. Show all posts
Showing posts with label idea. Show all posts

Monday, March 26, 2012

How to show a stored PDF

New to asp and have no idea what I'm doing wrong here. I just want to open a pdf that I have stored in a table and show it on the page. Here is my code. I keep getting theSystem.NullReferenceException was unhandled by user code.

<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:smithsdaConnectionStringtest %>"

ProviderName="<%$ ConnectionStrings:smithsdaConnectionStringtest.ProviderName %>"

SelectCommand="SELECT * FROM [correspondence] WHERE ([facilitiesID] = ?)">

<SelectParameters>

<asp:QueryStringParameterName="facilitiesID"QueryStringField="DACorr"Type="Int32"/>

</SelectParameters>

</asp:SqlDataSource>

<scriptrunat="server">

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)

Dim ScanDocAsNew DataViewDim argAsNew DataSourceSelectArguments

ScanDoc = SqlDataSource1.Select(arg)

Dim ScanLet(1)AsByte

ScanLet(0) =CByte(ScanDoc(0)("Letter"))

If ScanDocIsNot""Then

Response.Buffer =True

Response.Clear()

Response.ClearContent()

Response.ClearHeaders()

Response.ContentType ="application/pdf"

Response.BinaryWrite(ScanLet)

Response.End()

EndIf

EndSub

</script

Any Help greatly appreciated.

My suggestion would be to store the PDF files, all in one directory, then, in the database, store the names of the PDF files.

Then, show the relevant information in the database, using a Gridview, including one TemplateField, which would have a Hyperlink to the folder where the pDFs are stored, and the PDF itself. Then, when people clicked on the hyperlink, the PDF would show

|||

David,

Thanks for the reply. I wish I could do it that way, unfortunately they want the pdfs stored in the database so noone can accidentally delete them. The db has probably 200 stored pdfs associated with records and they need to be able to pull them up for viewing.

Thanks,

DeWayne

|||

I've changed the code to this and now it just opens a blank web page.

Dim ScanDocAsNew DataViewDim argAsNew DataSourceSelectArguments

ScanDoc = SqlDataSource1.Select(arg)

Dim ScanLet(1)AsByte

ScanLet(0) =CByte(Request.QueryString("Letter"))

If ScanDocIsNot""Then

Response.Buffer =True

Response.Clear()

Response.ClearContent()

Response.ClearHeaders()

'Response.AddHeader("content-disposition", "inline;filename=" + ScanLet)

Response.ContentType ="application/pdf"

'Response.AppendHeader("content-disposition", "inline;filename=" + "Scan.PDF")

Response.BinaryWrite(ScanLet)

Response.End()

'Else

' Response.Write("Error")

EndIf

I think I am on the right track but no PDF file yet.

|||

I finally got it, thanks to reading other posts in the forum and especially the one from adam v on how to strip the ole header. Now I just have to deal with .doc and .tif headers. This is a great forum and I have found lots of useful tips and tricks in here.

Thanks.

Here is the code I ended up with...

myConnection.Open()Dim myDataReaderAs OleDbDataReader = myCommand.ExecuteReader() myDataReader.Read()Dim intLoopCountAs Integer Dim intPositionAs Integer Dim ScanLetAs Byte() = myDataReader("letter")Do While intLoopCount < ScanLet.LengthIf ScanLet(intLoopCount) = 37Then'%If ScanLet(intLoopCount + 1) = 80Then'PIf ScanLet(intLoopCount + 2) = 68Then'DIf ScanLet(intLoopCount + 3) = 70Then'FIf ScanLet(intLoopCount + 4) = 45Then'- intPosition = intLoopCount intLoopCount = ScanLet.LengthEnd If End If End If End If End If intLoopCount = intLoopCount + 1Loop Dim bytStrippedData(ScanLet.Length - intPosition - 1)As Byte System.Buffer.BlockCopy(src:=ScanLet, srcOffset:=intPosition, dst:=bytStrippedData, dstOffset:=0, count:=ScanLet.Length - intPosition) Response.Clear() Response.ClearContent() Response.ClearHeaders() Response.ContentType ="application/pdf" Response.BinaryWrite(bytStrippedData) Response.Flush() Response.End() myConnection.Close() Response.Write("Person info successfully retrieved!")End UsingEnd Sub

Monday, March 19, 2012

How to set up permissions for a user, who need to work with SQL Server Agent

I am looking for a good idea or best practice for setting up a security plan which allows users to execute a specific job, owned by the SQL Server Agent Service Account.

I tried to use the msdb SQLAgentOperatorRole, but unfortunately I recognized, that every local job could be executed.

I would like to have only one job executed by the user and all others should be visible, but not executable.

What is the best practice for this request? Can Proxies and credentials be helpful and if yes, how do I have to use them?

In other words: what is the best approach for this request (end user should see and start specific jobs in the SQL Server Agent).

Thanks in advance

Norbert

Owner can execute job as well.|||

Thanks for the hint, but I do not want to have this user as an owner. The owner should be another account. This user (developer) should only have the capability to execute jobs we (DBA) provided to him. He should not see ALL jobs nor should he execute ALL jobs. I would like to set permissions in a way that he can start/stop/enable/disable ONE specific job.

Is there an easy way to realize it? Or maybe a more complicated way?

Regards

Norbert

How to set up a SQL Server for storing Chinese characters

Any idea what is the set up process is? I've tried a couple of
different character set and it's still not displaying the characters
correctly. I could insert the Chinese characters into a table using
INSERT with no error, but the SELECT statement shows "?"
Thanks for any help in advance.
John
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!
John,
Are you using the Unicode datatypes of Nchar, Nvarchar, Ntext to store your
Chinese characters?
Also, you might want to read the MSDN article "International Features in
Microsoft SQL Server 2000" at:
http://msdn.microsoft.com/library/de...Server2000.htm
as it has a lot of info on how to setup and use Chinese characters.
Regards,
John
"John Lee" <john.lee104@.verizon.net> wrote in message
news:#JAsC#3HEHA.3356@.TK2MSFTNGP11.phx.gbl...
> Any idea what is the set up process is? I've tried a couple of
> different character set and it's still not displaying the characters
> correctly. I could insert the Chinese characters into a table using
> INSERT with no error, but the SELECT statement shows "?"
> Thanks for any help in advance.
> John
>
> *** Sent via Developersdex http://www.codecomments.com ***
> Don't just participate in USENET...get rewarded for it!
|||Now I'm all set with saving and displaying the data. My next question
is how to script that for setting up a MSDE SQL server.
*** Sent via Developersdex http://www.codecomments.com ***
Don't just participate in USENET...get rewarded for it!
|||If you have access to SQL Server 2000 Standard or Developer Editions (or
above), you can use the Enterprise Manager to "generate SQL scripts" for
your database. If you don't have access to these Editions, there are several
"free" or low-cost "Enterprise Manager-like" tools, such as the following:
TOAD for SQL Server at http://www.toadsoft.com/toadss.html
and Microsoft's new SQL Server Web Data Administrator at:
http://www.microsoft.com/downloads/d...displaylang=en
Regards,
John
"John Lee" <john.lee104@.verizon.net> wrote in message
news:uMLEEBBIEHA.2836@.TK2MSFTNGP11.phx.gbl...
> Now I'm all set with saving and displaying the data. My next question
> is how to script that for setting up a MSDE SQL server.
> *** Sent via Developersdex http://www.codecomments.com ***
> Don't just participate in USENET...get rewarded for it!

How to set up a login that should execute a specific SQL Server Agent job

I am looking for a good idea or best practice for setting up a security plan which allows users to execute a specific job, owned by the SQL Server Agent Service Account.

I tried to use the msdb SQLAgentOperatorRole, but unfortunately I recognized, that every local job could be executed.

I would like to have only one job executed by the user and all others should be visible, but not executable.

What is the best practice for this request? Can Proxies and credentials be helpful and if yes, how do I have to use them?

In other words: what is the best approach for this request (end user should see and start specific jobs in the SQL Server Agent).

Thanks in advance

Norbert

Has no one an idea?

Regards

Norbert

|||

I hope, that someone xould give me some hints if it is possible to realize the scenario or not.

Regards

Norbert

How to set up a login that should execute a specific SQL Server Agent job

I am looking for a good idea or best practice for setting up a security plan which allows users to execute a specific job, owned by the SQL Server Agent Service Account.

I tried to use the msdb SQLAgentOperatorRole, but unfortunately I recognized, that every local job could be executed.

I would like to have only one job executed by the user and all others should be visible, but not executable.

What is the best practice for this request? Can Proxies and credentials be helpful and if yes, how do I have to use them?

In other words: what is the best approach for this request (end user should see and start specific jobs in the SQL Server Agent).

Thanks in advance

Norbert

Has no one an idea?

Regards

Norbert

|||

I hope, that someone xould give me some hints if it is possible to realize the scenario or not.

Regards

Norbert

Friday, February 24, 2012

how to set connection string value by using SET switch of dtexec sql server 2005 command

hi

I need to load a text file into sql server table using SSIS package.

the idea is to load this file with the help of dtexec command by giving the file path and name in the SET switch of dtexec command.

anyone having an idea; would be of great help.

Regards,

Salman Shehbaz.

Try using the package configuration wizard to get the property path:

Jamie talks about it here:

http://blogs.conchango.com/jamiethomson/archive/2007/03/13/SSIS_3A00_-Property-Paths-syntax.aspx

|||

o.kays

i finally got hold of the command;

here it is

execute master.dbo.xp_cmdshell 'dtexec /Ser "ServerName" /SQ "SSISPackagehName" /SET "\Package.Connections[ConnectionManagerName].Properties[ConnectionString]";"TextFilePath/Name"'

Regards,

Salman Shehbaz.