Here is my task I am storing pdf's in sql server. I would like to retrieve the binary data from sql server and write the pdf content into an existing aspx page to the appropriate pageview section. What is the best way to handle this. The code works below but it loads a new browser with the content. I need it to appear in it's tabbed section in the original aspx file. Any assistance you can give me would be greatly appreciated.
Thanks Jerry
oSQLConn.Open()
Dim myreaderAs SqlDataReadermyreader = myCommand.ExecuteReader
Response.Expires = 0
Response.Buffer =True
Response.Clear()
DoWhile (myreader.Read())Response.ContentType = ("application/pdf")
Response.BinaryWrite(myreader.Item("img_content"))Loop
Hi,
Well, you can add a Image control in your Tab control container, and create a page which works for displaying the image data from database.
The code snippet on that page to show the image data: (ShowImg.aspx)
// myRead is a DataReader object.Byte[] Buffer = (Byte[])myRead[0];//Outputthis.Response.Clear();this.Response.BinaryWrite(Buffer);this.Response.End();
And then, assign the ImageUrl property of the Image control.
this.Image1.ImageUrl = "showimg.aspx"
Of course, if you want to show different pictures based on the parameters like following:
this.Image1.ImageUrl = "showimg.aspx?imageid=123"
Then, you can receive the parameter on ShowImg.aspx, make a query with that parameter against the database and return the corresponding image data.
Thanks.
|||Thanks it looks like this solution will work just fine.
Tuesday, February 14, 2012
Best way to inform .NET app of change in DB content
I have a number of servers that 'cache' data from a table in SQL Server. At some later time one of the servers may update a set of the data. When this occurs I'd like to alert the other servers that the data has changed so they can refresh/drop it from the local cache/ The data can cover a number of rows from one of the DB tables (depends on how the cache is configured). The table is simply a persistent object store.
With .NET being an integral part of SQL2005, does anyone have any guidance on how to achieve this efficiently. I'd like to think there would be a .NET event mechanism built in, but I've not seen anything like this!
Thanks in advance!You can use SQL Server Notification Services: http://www.devx.com/dbzone/Article/28522|||
You can use the SqlNotification class in .NET 2.0 - this can be used in both SQL Server 2000 and SQL Server 2005
|||Thank you both for your answers! I had look at SQL Notification Services but wondered if this is too 'heavyweight' for my needs. I'll take a close look at the .NET 2 feature.
|||You can test it out by visiting http://msdn.demoservers.com and look for the SQL Server 2005 and ADO.NET hands-on lab as this covers using the SqlNotification and SqlDependency objects in .NET 2.0|||Look up topics on Query Notifications and SqlDependency in the 2005 MSDN Library. Note that these are not the same as Notification Services. They're much lighter-weight, and focused on firing application events rather than sending external notifications. -- Adam MachanicSQL Server MVPhttp://www.datamanipulation.net-- <adamhearn@.discussions..microsoft.com> wrote in message news:68627a2a-01ab-42f4-b950-54dd2e1a3041@.discussions.microsoft.com...Previously had a 'prototype' (.NET 1.0, SQL Server 2000, CCW to .NET) whereby an update trigger called out to our .NET app. Obvioulsy now SQL Server 2005 is nearly upon us I'd like to explore a better mechanism in order to consider the next phase of deployment (.NET 2, SQL Server 2005).I have a number of servers that 'cache' data from a table in SQL Server. At some later time one of the servers may update a set of the data. When this occurs I'd like to alert the other servers that the data has changed so they can refresh/drop it from the local cache/ The data can cover a number of rows from one of the DB tables (depends on how the cache is configured). The table is simply a persistent object store.With .NET being an integral part of SQL2005, does anyone have any guidance on how to achieve this efficiently. I'd like to think there would be a .NET event mechanism built in, but I've not seen anything like this!Thanks in advance!Best way to inform .NET app of change in DB content
I have a number of servers that 'cache' data from a table in SQL Server. At some later time one of the servers may update a set of the data. When this occurs I'd like to alert the other servers that the data has changed so they can refresh/drop it from the local cache/ The data can cover a number of rows from one of the DB tables (depends on how the cache is configured). The table is simply a persistent object store.
With .NET being an integral part of SQL2005, does anyone have any guidance on how to achieve this efficiently. I'd like to think there would be a .NET event mechanism built in, but I've not seen anything like this!
Thanks in advance!You can use SQL Server Notification Services: http://www.devx.com/dbzone/Article/28522|||
You can use the SqlNotification class in .NET 2.0 - this can be used in both SQL Server 2000 and SQL Server 2005
|||Thank you both for your answers! I had look at SQL Notification Services but wondered if this is too 'heavyweight' for my needs. I'll take a close look at the .NET 2 feature.
|||You can test it out by visiting http://msdn.demoservers.com and look for the SQL Server 2005 and ADO.NET hands-on lab as this covers using the SqlNotification and SqlDependency objects in .NET 2.0|||Look up topics on Query Notifications and SqlDependency in the 2005 MSDN Library. Note that these are not the same as Notification Services. They're much lighter-weight, and focused on firing application events rather than sending external notifications. -- Adam MachanicSQL Server MVPhttp://www.datamanipulation.net-- <adamhearn@.discussions..microsoft.com> wrote in message news:68627a2a-01ab-42f4-b950-54dd2e1a3041@.discussions.microsoft.com...Previously had a 'prototype' (.NET 1.0, SQL Server 2000, CCW to .NET) whereby an update trigger called out to our .NET app. Obvioulsy now SQL Server 2005 is nearly upon us I'd like to explore a better mechanism in order to consider the next phase of deployment (.NET 2, SQL Server 2005).I have a number of servers that 'cache' data from a table in SQL Server. At some later time one of the servers may update a set of the data. When this occurs I'd like to alert the other servers that the data has changed so they can refresh/drop it from the local cache/ The data can cover a number of rows from one of the DB tables (depends on how the cache is configured). The table is simply a persistent object store.With .NET being an integral part of SQL2005, does anyone have any guidance on how to achieve this efficiently. I'd like to think there would be a .NET event mechanism built in, but I've not seen anything like this!Thanks in advance!