Working With Compressed Data

Apr 27, 2007

Hello,
I have a table of compressed data and am looking for an efficient way to expand the data for reporting purposes.
The table is used to store the number of hours a given contractor works and is stored in the following fashion:

cntHours
58
20
58
20

The first row represents the number of sequential days where an employee worked the same # of hours. Once the # of hours changes, a new record is created. In this simple example, the first row shows an employee working Monday-Friday (5) for a total of 8 hours each day. The second row represents the weekend (2 days) where the employee worked 0 hours.

What I need to do is explode this out to show 1 record per day. Ideally I'd like to write a function to do this as I would be linking to another table which has the start and end date for the contractor and would allow me to apply individual dates to each record based on the contractor start date through to the end date.

Thanks for any help you can provide!

View 2 Replies


ADVERTISEMENT

Trying To Apply A Non-compressed Snapshot When It Is Compressed In A Cab File

Jul 19, 2007

Noticed weird activity today with pull merge.



When your snapshot is set to be delivered via ftp and compressed in a cab file. If you add a new article to your publication and re-run the snapshot the agent will be unable to pull the snapshot down as it for some reason doesnt think its compressed. It is failing to find the scripts it needs inside the cab file despite the cab file existing in the correct location.



Here is the error.



2007-07-19 09:57:29.855 Snapshot files will be downloaded via ftp
2007-07-19 09:57:29.886 Connecting to ftp site 'SQL3'
2007-07-19 09:57:29.933 The schema script 'empActive_127.sch' could not be propagated to the subscriber.
2007-07-19 09:57:29.933 Category:NULL
Source: Merge Replication Provider
Number: -2147201001
Message: The schema script 'empActive_127.sch' could not be propagated to the subscriber.
2007-07-19 09:57:29.933 Category:AGENT
Source: SQL2SQL2005
Number: 20033
Message: The process could not retrieve file 'SQL3_CCUSA_ATLAS_SYSTEM TABLES/20070719055712/empActive_127.sch' from the FTP site 'SQL3'.
2007-07-19 09:57:29.949 CategoryS
Source:
Number: 12003
Message: 200 Type set to I.
200 PORT command successful.
550 SQL3_CCUSA_ATLAS_SYSTEM TABLES/20070719055712/empActive_127.sch: The system cannot find the file specified.
550 SQL3_CCUSA_ATLAS_SYSTEM TABLES/20070719055712/empActive_127.sch: The system cannot find

View 1 Replies View Related

Use Bcp To Output Data To A Compressed (zipped) Folder

Jan 25, 2007

Hi all,

I am trying to use bcp to output data to a compressed (zipped) folder.
The bcp command is called from a step in scheduled job in SQL 2005 (T-SQL) similar to:

SET@chvCommand =
'bcp [working_t] out D:EprojectsEdataCdata200701.dat'
+ ' -c -STPISQL -T'

EXECUTE master.dbo.xp_cmdshell @chvCommand, NO_OUTPUT

.... where Cdata is a compressed (zipped) folder.
The scheduled job seems to work without errors, but afterwards there is nothing in the compressed folder.
If Cdata is a regular folder everything works fine.


Thanks for you insight.

View 8 Replies View Related

SQL 2012 :: Extracting Data From Compressed CLOB XML Using SSIS?

Apr 14, 2014

Source System : Oracle

Target System : Ms Sql Server 2012

ETL Tool Used : SSIS

My source data is present in XML File which is stored in CLOB column Of Oracle. CLOB column is compressed.I need to Migrate data by Uncompressing XML to SQL 2012 .

Do I need to define XML column in SQL Server 2012 for storing Uncompressed CLOB values ?

How to uncompress the clob and extract the required data from XML using SSIS .

View 2 Replies View Related

Transmission Of Compressed Snapshots

Feb 2, 2007

I am using SQL2005 merge replication and have pull subscribers on a low bandwidth link

I am compressing the snapshot into an alternate folder. Files are not put into the default folder

When I start a synchronization, I would expect the cab file to be copied to the subscriber and then the files to be extracted locally at the subscriber in order to apply the snapshot

However, what appears to be happening is that the files are being extracted from the cab file on the publisher (in a UNC specified directory) and then copied in their uncompressed form to the subscriber - resulting in an extremely slow snapshot application.

Any ideas what I am doing wrong? I have read about the options for using FTP to transfer snapshot files, but I am not clear whether I have to use FTP in order to transmit a compressed snapshot. I don't want to use FTP unless I need to.

Any suggestions would be much appreciated

aero1

View 8 Replies View Related

SQL 2012 :: Copy-Only Compressed Backups

Jun 11, 2015

I just completed a copy-Only compressed backup of a DB (with a FULL Recovery Model ) on SQL Server 2012 and the resulting backup (the bak file) is 1/100th the size of the data & log file. Is the compression in SQL Server 2012 just that good or did something else happen that I did not catch? Below is the T-SQL to re-create the backup. The size of the data file is 750MB and the log file is 75GB and is %95 used according to the SQLPERF command.

Does the compression in SQL Server 2012 simply that good

BACKUP DATABASE [MYBIGOLEDB] TO DISK = N'Z:Microsoft SQL ServerMSSQL11.MSSQLSERVERMSSQLBackupMYBIGOLEDB_20150611.bak' WITH COPY_ONLY, NOFORMAT, INIT, NAME = N'MYBIGOLEDB-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10
GO

View 1 Replies View Related

Compressed Folder && Query Speed

Nov 23, 2005

One way to save storage space is to put the SQL data files into a compressedfile. Has anyone got any idea how this will affect the query speed?

View 2 Replies View Related

Compressed Snapshot With Push Subscribers

Oct 16, 2007

Hi,

I have a server in our central location which is a compressed snapshot publisher. I have 2 push subscribers in remote locations on very slow WAN links. I would like the snapshot cabinet file to be uncompressed at the subscribers location rather than the publisher location. Is this possible with push subscribers? I want to manage the pushing of data to the remote subscribers from the publisher location.

I understand the default with push subscriptions is to uncompress the cabinet file at the publisher location.

Thanks,
Mark.

View 3 Replies View Related

Backup/Restore From/to Compressed Files

Apr 24, 2007

Hi everyone,



already tried this in other SQL forums, but maybe i have some luck here.



I need mainly to restore database backups from customers. They arrive in all kind of formats (zip, rar, gz). I'd like to be able to restore those directly from the compressed file, because i'm talking up to 7GB rar files which take a while to uncompress in a separate step.



I'm working for 6 years in R&D environments, but mostly on Linux/Oracle where this is an easy task using pipes, but i haven't found a sinlge web page, post or even script to do this with MSSQL. The VDI is not really what i'm looking for, so aren't backup software like SQLBackup, Litespeed etc. because i can't force the customer to use those.



Anybody any idea or even the same problem maybe with solution?

Thx.

View 10 Replies View Related

Reading Compressed Files - Problem With X00

Jan 31, 2006

I am trying to read a 36 byte files that contains compressed data. I create my Flat File data source and SSIS reads it fine UNTIL it hits a x00 in the file. Then it stops reading and I can't get any data after it. There is data after the x00. Here the entire hex string: C7 C7 CF 6A 00 00 05 02 3D 03 21 01 E0 02 00 00 00 00 00 00 00 00 3D 3C 1E FD 02 C8 00 00 00 AE 41 E3 28 7C

To test, I changed the two x00 in bytes 5 and 6 to x01 and SSIS read until the next x00.

Anyone have any ideas?

Thanks,

Jack Lavender

View 3 Replies View Related

SQL Server 2008 :: Exporting BCP To A Compressed File (Rar)

Nov 2, 2015

I have this bcp

EXEC xp_cmdshell 'bcp "SELECT top 10 * FROM [db].dbo.[u_activity]" queryout "C:bcpCustomers.csv" -c -b 10000 -t~ -S 10.20.8.149 -U user-P password'

which throws the data into a csv, but the issue is I also need to compress the file down in a .rar file,

can this be done in a SP while still executing the above bcp ?

View 2 Replies View Related

Reporting Services :: How To Show Compressed Image In Report

Sep 14, 2012

I have created a new report.what i do in application is i  compress the image and save it in database.now i need to retrieve the compressed image and display in the report. I have used the following code to decompress the binary data save in the image.

I dont know after that what should i do. How to show the picture in SSRS Report. I need to show picture in many reports.one of my doubt is how to call this function in SSRS Report. The function accepts input as byte but in database the column in varbinary.

Should I convert the input type of function to varbinary instead of byte array?

Public Function Decompress(ByVal arr As Byte()) As Byte()
Dim notCompressed As Boolean
notCompressed = False
Dim MS As MemoryStream
MS = New MemoryStream()

[Code] ....

View 4 Replies View Related

SQL 2005 Failed - Cannnot Install Files To The Compressed Or Encrypted..

Feb 15, 2007

Hi, I am trying to lean ASP.NET. So I was trying to install SQL Server too. But, I could not install. The aleart box popped up:

"SQL Server set up cannot install files to the compressed or encrypted folder: C:Program FilesMicrosoft SQL Server"

Before this, I also got a warning that the hardware of my computer does not meet the hardware requirement.

I would like to know how I can install SQL Server into my computer. Or, shouldn't I do that? To learn ASP.NET I want to have a database ready. If I can not use SQL Server, I may try Access or something smaller...

Thanks in advance.



yyokota2

View 1 Replies View Related

Having Trouble Following Tutorial - Working With Data In ASP.NET 2.0 :: Creating A Data Access Layer

Nov 1, 2006

HiI'm having problems following the tutorial on creating a data access layer -  http://www.asp.net/learn/dataaccess/tutorial01cs.aspx?tabid=63 - when I try to compile in Visual Studio 2005 I get namespace could not be found. I followed exactly the tutorial - I created a dataset and added this code in my aspx page.  <asp:GridView ID="GridView1" runat="server"             CssClass="DataWebControlStyle">               <HeaderStyle CssClass="HeaderStyle" />               <AlternatingRowStyle CssClass="AlternatingRowStyle" />In my C# file I added these lines...    using NorthwindTableAdapters; <<<<<this is the problem - where does this come from?   protected void Page_Load(object sender, EventArgs e)    {        ProductsTableAdapter productsAdapter = new         ProductsTableAdapter();        GridView1.DataSource = productsAdapter.GetProducts();        GridView1.DataBind();    }Thanks in advance

View 6 Replies View Related

SQL Server Cannot Install Files To The Compressed Or Encryted Folder: C:program Filesmicrosoft SQL Server

Mar 5, 2007

Where do I go in my computer to correct this problem so that I can complete the installation?

View 3 Replies View Related

Working With Data......

Dec 13, 2007

 
I have what I feel is a unique problem I am trying to solve.  I am making a small program to be run by the windows task scheduler in server 2003 environment.  The program is to open on schedule and pull information from a progress db and then dump it into a sql db I have made to hold the information I need from it.  I am trying to use Comboboxes to hold the information from the progress db and then I am trying to make a connection to my sql db and then save all the information waiting in the Comboboxes into the sql db.  Do you have any suggestions for doing this?  Any help is greatly appreciated.  I have included my code below.
 
Thank you.
 
Imports System.Data.SqlClientPublic Class Form1
Dim cmd1 As New SqlCommandDim cnn1 As New SqlConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DataSet1.DataTable1' table. You can move, or remove it, as needed.Me.DataTable1TableAdapter.Fill(Me.DataSet1.DataTable1)
ChangeIndex()
'SaveRecaps()
End SubPublic Sub SaveRecaps()
cnn1.ConnectionString = "Data Source=.SQLEXPRESS;AttachDbFilename=C:Documents and SettingsjbreckerMy DocumentsVisual Studio 2005WebSitesRecapsApp_DataSalesmanProfits.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
cmd1.CommandType = CommandType.StoredProcedure
cmd1.CommandText = "StoredProcedure1"
cmd1.Connection = cnn1cmd1.Parameters.AddWithValue("@SalesmanID", SalesmanID.SelectedValue)
cmd1.Parameters.AddWithValue("@BillingMonth", DateTime.Today.Month)cmd1.Parameters.AddWithValue("@BillingDay", DateTime.Today.Day)
cmd1.Parameters.AddWithValue("@BillingDate", DateTime.Today)cmd1.Parameters.AddWithValue("@SalesMTD", Sales.SelectedValue)
cmd1.Parameters.AddWithValue("@ProfitMTD", Profit.SelectedValue)cmd1.Parameters.AddWithValue("@SalesmanName", AddressName.Text)
Try
cnn1.Open()
cmd1.ExecuteNonQuery()
cnn1.Close()Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error 101")
End Try
End SubPrivate Sub ChangeIndex()
Dim n As Integer
For n = 1 To Me.SalesmanID.Items.Count 'Me.DataSet1.DataTable1.CountMe.SalesmanID.SelectedIndex = n
Me.AddressName.SelectedIndex = nMe.Profit.SelectedIndex = n
Me.Sales.SelectedIndex = n
Next
End SubPrivate Sub AddressName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddressName.SelectedIndexChanged
Me.SalesmanName.Text = AddressName.SelectedValueMe.SalesmanNumber.Text = SalesmanID.SelectedValue
Me.SalesmanProfit.Text = Profit.SelectedValueMe.SalesmanSales.Text = Sales.SelectedValue
SaveRecaps()End Sub
End Class

View 2 Replies View Related

DB Engine :: Compressed Backup While Restoring Backup File

Sep 8, 2015

I got full backup on daily schedule its taking more space on Drive because each file has more than 25GB.I am using SLQ server 2008R2 so I'm looking to take the backup with compression instead of uncompressed Backup. What are the impacts of compressed backup. Is there any problems with compressed backup while restoring the backup file.

View 8 Replies View Related

Trying To Chop Up My Data -- Not Working The Way I Want It Too.

Mar 21, 2005

Hello everyone again.

I'm trying to manipulate one of my collumns. I have one collumn called fundID (where a 7 diget number is stored). These numbers are sequestial (not identifers w/n the SQL database) but they have meaning in the order they are in....for instance:

1100000 is a higher level then
1110000 and this is a higher level then
1111000 (which is the lowest level)

however since they are all part of the 11 group they all belong w/n the same group.

What I've done is created two more collumns and I want to deceminate the field where these id's are kept.

So if my key is 1110000 I want to list in the centerKey collumn that the Center Key is 1100000 (becasue it is the one higher then the 1110000 key)....This is all for reporting purposes that i'm doing in .net and has been the easist way to relate all of these records together.

If someone could lead me in the right direction on how I could write a stored proc that would break these down properly that would be great...Im trying to base it on the Substring right now but that does not seem to be working....if there are any more ideas I appricate it.

Thanks in advance everyone as always.

RB

View 1 Replies View Related

Working With Image Data.

May 24, 2000

I have a ot of images in my hard disk and I want to put
these ina table in a column declared as an image datatype.
How do I do it?
After I am done with that, I want to select my images and should able to see the pictures.
Can any one help?
I know about the textptr function but the booksonline doesn't show mw how
to set my textptr to a specific location on my hard rive.
Any help is appreciated.
I need this because the customers do send the images of their proucts which should go into the database.

Thanks

View 1 Replies View Related

How To Get Data For First Working Day Of The Week

Jul 29, 2014

Here i am providing reference site.I need to get the data same as it is [URL]....

Here I am passing "from" and "to" dates to query based on this i have to get the only monday's data from the database in given dates.

View 4 Replies View Related

Working With Smalldatetime Data Type

Mar 11, 2004

Hello all,

if i save a date value within a smalldatetime field, then later want to edit the record and set the smalldatetime field to nothing, how can i do this. I've tried populating the field with Null, and anything else, without success. Any suggestions?

Sammy

View 2 Replies View Related

Data Source Expression Not Working

Jun 6, 2007

Hello, I am trying to use a data source expression but I'm getting an error. Here is my data source expression:



="data source=" & Parameters!ServerName.Value & ";initial catalog=AdventureWorks"



I have created a report parameter called ServerName. However, when I deploy the report and report viewer opens, I get the following error:



An error has occurred during report processing. (rsProcessingAborted) Error during processing of the ConnectString expression of datasource €˜AdventureWorks€™. (rsDataSourceConnectStringProcessingError)



Is there some really obvious step I am missing here? The relevant parts of my rdl are below.



Thanks in advance



<DataSources>

<DataSource Name="AdventureWorks">

<ConnectionProperties>

<ConnectString>="data source=" &amp; Parameters!ServerName.Value &amp; ";initial catalog=AdventureWorks"</ConnectString>

<DataProvider>SQL</DataProvider>

</ConnectionProperties>

<rdataSourceID>(some stuff here)</rdataSourceID>

</DataSource>

</DataSources>

...

<ReportParameters>

...

<ReportParameter Name="ServerName">

<DataType>String</DataType>

<Prompt>ServerName</Prompt>

</ReportParameter>

</ReportParameters>

View 3 Replies View Related

Data-driven Subscription Not Working

May 30, 2007

I created a data-driven subscription for my report with "Null Delivery Provider" set in report manager. I set the processing to "On a schedule created for this subscription" and scheduled the report to "run once" in the next 1 minute so I could test it. The subscription added successfully, but I don't see the "last run information" even after 5 minutes. Am I missing something?



Thanks in advance!!!

View 1 Replies View Related

Working With Data In A Mobile Solution

Mar 19, 2006

Im doing a project using VS2k5 and sql server2k5. Its a mobile project and this is my first time working with SQL and Visual Basic. I need to know how to add data to my database from the windows form.I have however been able to use the tableadapters and some sql statements to read data from the database in my forms. Can anyone here help me?

View 6 Replies View Related

Cube With Monthly Data Chunks Not Working

Apr 3, 2008

I have a table based around requisitions, and each requisition has a number of positions. That number can change over time through updates to pertinent rows rather than through transaction-like records that record an entire history, and I'm only able to get a monthly snapshot of the table. What I decided to do is still use one table for OLAP (fact_requisitions) but add a column called period_key that refers to the month the data comes from. So if I have two months of data then the table has each requisition twice, possibly with differing position counts, and new requisitions from the second month are only present once. Then I tried to filter the MDX query like so:

SELECT {
([Dim TimeRequestClosed].[Year - MonthNumber].[Year_Text].&[2008].&[1],[Dim Requisitions].[Period].[Period Key].&[200801])
}
ON COLUMNS,
NON EMPTY
{
([Dim Location].[Region Name].MEMBERS, [Dim Location].[Period Key].&[200801])
}
ON ROWS
FROM
[Requisitions]
WHERE
[Measures].[Request Closed Date Count]


This query doesn't work even though the data is there, it just returns nulls. Am I going about this all wrong? If not, what might I be doing wrong, and how would I get the query to return more than one period (e.g. tell Dim Requisition to match up with Dim Location on the period key)?

View 2 Replies View Related

Excel Data Mining Add In: Order By Not Working

Apr 24, 2007

Hello,



I am trying insert the "Order by" clause into DMX but nothing is working.



INSERT INTO MINING STRUCTURE [ARS] (
[OrderID],
[Product_Table](SKIP, [Product])
)
SHAPE {
OPENQUERY ([dwMDA on PSD_TEST_TEST], 'Select Top 30000 "OrderID"
From "dwMDA"."dbo"."vDetail" Order By "OrderID"')
} APPEND
( {
OPENQUERY ([dwMDA on PSD_TEST_TEST], 'Select Top 30000 "OrderID","Product"
From "dwMDA"."dbo"."vDetail" Order By "OrderID"')} RELATE [OrderID] TO [OrderID]
) AS T



This is the DMX for market basket analysis.



I am also unable to use "order by" when i pull data into excel.



here's an example of something that doesn't work:



Select Top 20000 "OrderID","ProductGroupDescription"
From "dwMDA"."dbo"."vDetail"

Order By "OrderID"



Can someone show me the exact working SQL commands they are using for the "Order By" clause when they import data from sql into an excel spreadsheet?



Even better would be if someone

1. Open excel, and go to the data mining tab

2. Click on the Cluster Button

3. Select Analysis Service Data Source

4. Input a command the includes "Order By"

5. Run the model

6. Show me the tracer.



Thanks



Davy

View 1 Replies View Related

Import Data Wizard Not Working Remotely

Mar 11, 2008

I have a need to do a quick and dirty import of a flat file into a 2005 database. When I try to run the Import Export wizard from my machine, I get an error when it tries to connect to the database server. It's the lovely generic error that says my server doesn't allow remote connections. Well it does allow remote connections. I can RDP to the server and run the same import and it works. So why doesn't it work when I try to run it from my machine? Am I missing a setting somewhere?

I am using SQL Native client trying to connect to a named instance of sql (2005, sp2) as my destination.


TIA
-A.

View 7 Replies View Related

Working With Obscure Data Types In Native C++

Aug 8, 2007

Howdy folks!

Next question of the day:

I have four data types that I can't (or at least I think I can't) use a _variant_t for conversion. The four types are:

- bigint (I'm sending to a LARGE_INTEGER data structure)
- guid (I'm sending to a GUID data structure)
- numeric (I'm sending to a DB_NUMERIC data structure)
- datetime (I'm sending to a DBTIMESTAMP data structure)

I'm looking for a way to locally convert (i.e. not a provider conversion) each to a string. For all the other data types I've been able to cast using _variant_t's, but with these I can't seem to find a way. What are y'all suggestions for working with these data types?

Thanks!

View 9 Replies View Related

Next And Previous Buttons Working With Unbound Data?

Apr 3, 2008

Hello.

I am trying to implement Next and Previous buttons on a web page that uses CE as the database, and having some trouble getting the logic figured out. The data is unbound and I'm not returning it all at once, so paging through it an item at a time isn't possible. Because of the high volume, I was thinking I could pass in the record ID each time I need to retrieve a record and every time the user hits the next or previous button, I'll just requery for the record I need. Does that sound reasonable?

In my main page, I'm using the ViewState to store the record ID that I need to acquire. This part works--it gives me the highest ID number (so that I get the most recent record):

if (!IsPostBack) {
// Start out with the most recent record in the selected category. GetHighestConfessionID() will return
// the ID of the most recent confession.
ViewState ["ConfessionID"] = mySearch.GetHighestConfessionID (int.Parse(ViewState["Category"].ToString()));
}


Here's where the trouble comes in--I need to go to the next record in the database when the user hits Next, but I don't know how to do that. My big idea was to issue this command in the Next button:

ViewState ["ConfessionID"] = GetNextConfessionID (ViewState ["ConfessionID"]);


But I'm not quite sure how to increment/decrement my ConfessionID, since it's not guaranteed to be sequential (a record could have been deleted).

If the user hits Next, for example, I need to query for the next record ID, but I'm not sure how to do that since they're not necessarily sequential.

Is there a simple solution? I feel like I'm making a mountain out of a molehill.

Thanks in advance for any ideas.

View 2 Replies View Related

Data Mining :: Calculation Not Working Trigger

Apr 20, 2015

In My Table , I have Three Column like Qty,Price and Total, I create a Trigger for this . 

Table:
CREATE TABLE [dbo].[tbl_SO](
[SoNo] [varchar](50) NULL,
[Qty] [int] NULL,
[price] [numeric](18, 2) NULL,
[total] [numeric](18, 2) NULL
) ON [PRIMARY]

[code]...

Input :
1) UPDATE TBL_SO SET QTY='10',Price='100' Where SONo='10'
2)UPDATE TBL_SO SET QTY='10',Price='100'  Total=Qty*Price Where SONo='10'

Output:
What I get? I tried both 1 and 2, It(Query) does not work on first time,I executed (Query) second time It works.Why?What I need?   How to work on First Time?

View 6 Replies View Related

Storeing PDF's In SQL 2005 Using Image Data Type, Not Working...

Jul 20, 2007

Hi everyone, I have an odd problem.  I have a generic upload/download ASP.net page that allows the upload and download of and type of file.  I have so far tested the following file types:
XLS, MDB, JPG, DLL, EXE, PDF, TXT, SWF, and GIF
All of these upload and download fine, EXCEPT PDF's.  I have tried 4 different PDF's and all open prior to upload/download, but after uploading and downloading, I get the following (from Adobe Reader) error upon trying to open:
"There was an error opening this document.  The file is damaged and could not be repaired"
 Here's my current code:
9      Protected Sub ItemCommand_Click(ByVal sender As System.Object, ByVal e As RepeaterCommandEventArgs)10   11       If e.CommandName = "open" Then12         Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("data_partsbranding").ConnectionString)13         Dim sSQL As New StringBuilder14         Dim sqlCmd As SqlCommand15         Dim sqlReader As SqlDataReader16         Dim byteArray(UploadedFile.PostedFile.InputStream.Length) As Byte17   18         sSQL.Append(" SELECT      * ")19         sSQL.Append(" FROM        [survey_document] ")20         sSQL.Append(" WHERE       [sd_document_code] = @sd_document_code ")21   22         sqlCmd = New SqlCommand(sSQL.ToString, sqlConn)23   24         sqlCmd.Parameters.AddWithValue("@sd_document_code", e.CommandArgument)25   26         sqlConn.Open()27         sqlReader = sqlCmd.ExecuteReader28   29         While sqlReader.Read30   31           Response.ContentType = sqlReader("sd_mime_type").ToString()32           Response.BinaryWrite(sqlReader("sd_document"))33           Response.AddHeader("Content-Disposition", "attachment;filename=" & sqlReader("sd_file_name").ToString())34         End While35   36         sqlReader.Close()37         sqlConn.Close()38   39       End If40   41     End Sub42   43     Protected Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click44   45       'Make sure a file has been successfully uploaded46       If UploadedFile.HasFile Then47   48         'Connect to the database and insert a new record into Products49         Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("data_partsbranding").ConnectionString)50         Dim sSQL As New StringBuilder51         Dim sqlCmd As SqlCommand52         Dim byteArray(UploadedFile.PostedFile.InputStream.Length - 1) As Byte53   54         'Read the files binary data into a Byte array55         UploadedFile.PostedFile.InputStream.Read(byteArray, 0, byteArray.Length)56   57         sSQL.Append(" INSERT INTO [survey_document] ")58         sSQL.Append(" (           sd_document ")59         sSQL.Append(" ,           sd_title ")60         sSQL.Append(" ,           sd_file_name ")61         sSQL.Append(" ,           sd_upload_date ")62         sSQL.Append(" ,           sd_mime_type ")63         sSQL.Append(" ) VALUES (  @sd_document ")64         sSQL.Append(" ,           @sd_title ")65         sSQL.Append(" ,           @sd_file_name ")66         sSQL.Append(" ,           @sd_upload_date ")67         sSQL.Append(" ,           @sd_mime_type ")68         sSQL.Append(" ) ")69   70         sqlCmd = New SqlCommand(sSQL.ToString, sqlConn)71   72         sqlCmd.Parameters.AddWithValue("@sd_title", FileTitle.Text.Trim())73         sqlCmd.Parameters.AddWithValue("@sd_mime_type", UploadedFile.PostedFile.ContentType)74         sqlCmd.Parameters.AddWithValue("@sd_file_name", System.IO.Path.GetFileName(UploadedFile.PostedFile.FileName))75         sqlCmd.Parameters.AddWithValue("@sd_upload_date", Now)76         sqlCmd.Parameters.AddWithValue("@sd_document", byteArray)77   78         sqlConn.Open()79         sqlCmd.ExecuteNonQuery()80         sqlConn.Close()81   82       Else83   84         'Either the file upload failed or no file was selected85   86       End If87   88     End SubI have also tried the following code as a result of searching far and wide, trying other peoples methods:
 1 Protected Sub ItemCommand_Click(ByVal sender As System.Object, ByVal e As RepeaterCommandEventArgs)
2
3 If e.CommandName = "open" Then
4 Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("data_partsbranding").ConnectionString)
5 Dim sSQL As New StringBuilder
6 Dim sqlCmd As SqlCommand
7 Dim sqlReader As SqlDataReader
8 Dim byteArray(UploadedFile.PostedFile.InputStream.Length) As Byte
9
10 sSQL.Append(" SELECT * ")
11 sSQL.Append(" FROM [survey_document] ")
12 sSQL.Append(" WHERE [sd_document_code] = @sd_document_code ")
13
14 sqlCmd = New SqlCommand(sSQL.ToString, sqlConn)
15
16 sqlCmd.Parameters.AddWithValue("@sd_document_code", e.CommandArgument)
17
18 sqlConn.Open()
19 sqlReader = sqlCmd.ExecuteReader
20
21 While sqlReader.Read
22
23 Dim buffer() As Byte = sqlReader("sd_document")
24 Dim blen As Integer = CType(sqlReader("sd_document"), Byte()).Length
25
26 Response.ContentType = sqlReader("sd_mime_type").ToString()
27 Response.OutputStream.Write(buffer, 0, blen,)
28 Response.AddHeader("Content-Disposition", "attachment;filename=" & sqlReader("sd_file_name").ToString())
29 End While
30
31 sqlReader.Close()
32 sqlConn.Close()
33
34 End If
35
36 End Sub
37
38 Protected Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
39
40 'Make sure a file has been successfully uploaded
41 If UploadedFile.HasFile Then
42
43 'Connect to the database and insert a new record into Products
44 Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("data_partsbranding").ConnectionString)
45 Dim sSQL As New StringBuilder
46 Dim sqlCmd As SqlCommand
47 Dim byteArray(UploadedFile.PostedFile.InputStream.Length - 1) As Byte
48
49 'Read the files binary data into a Byte array
50 UploadedFile.PostedFile.InputStream.Read(byteArray, 0, byteArray.Length)
51
52 sSQL.Append(" INSERT INTO [survey_document] ")
53 sSQL.Append(" ( sd_document ")
54 sSQL.Append(" , sd_title ")
55 sSQL.Append(" , sd_file_name ")
56 sSQL.Append(" , sd_upload_date ")
57 sSQL.Append(" , sd_mime_type ")
58 sSQL.Append(" ) VALUES ( @sd_document ")
59 sSQL.Append(" , @sd_title ")
60 sSQL.Append(" , @sd_file_name ")
61 sSQL.Append(" , @sd_upload_date ")
62 sSQL.Append(" , @sd_mime_type ")
63 sSQL.Append(" ) ")
64
65 sqlCmd = New SqlCommand(sSQL.ToString, sqlConn)
66
67 'sqlCmd.Parameters.AddWithValue("@sd_title", PictureTitle.Text.Trim())
68 'sqlCmd.Parameters.AddWithValue("@sd_mime_type", UploadedFile.PostedFile.ContentType)
69 'sqlCmd.Parameters.AddWithValue("@sd_file_name", System.IO.Path.GetFileName(UploadedFile.PostedFile.FileName))
70 'sqlCmd.Parameters.AddWithValue("@sd_upload_date", Now)
71 'sqlCmd.Parameters.AddWithValue("@sd_document", byteArray)
72
73 sqlCmd.Parameters.Add(New SqlParameter("@sd_mime_type", SqlDbType.VarChar))
74 sqlCmd.Parameters.Add(New SqlParameter("@sd_title", SqlDbType.VarChar))
75 sqlCmd.Parameters.Add(New SqlParameter("@sd_upload_date", SqlDbType.DateTime))
76
77 sqlCmd.Parameters.Add(New SqlParameter("@sd_file_name", SqlDbType.VarChar))
78
79 sqlCmd.Parameters.Add(New SqlParameter("@sd_document", SqlDbType.Image))
80
81 Dim bArray(UploadedFile.PostedFile.ContentLength - 1) As Byte
82
83
84
85
86
87
88 UploadedFile.PostedFile.InputStream.Read(bArray, 0, UploadedFile.PostedFile.ContentLength)
89
90 sqlCmd.Parameters("@sd_mime_type").Value = UploadedFile.PostedFile.ContentType
91 sqlCmd.Parameters("@sd_title").Value = PictureTitle.Text.Trim()
92 sqlCmd.Parameters("@sd_upload_date").Value = Now
93
94 sqlCmd.Parameters("@sd_file_name").Value = System.IO.Path.GetFileName(UploadedFile.PostedFile.FileName).ToLower
95
96 sqlCmd.Parameters("@sd_document").Value = bArray
97
98
99 sqlConn.Open()
100 sqlCmd.ExecuteNonQuery()
101 sqlConn.Close()
102
103 Else
104
105 'Either the file upload failed or no file was selected
106
107 End If
108
109 End Sub
110

 This method atleast gives a different error:
 "Adobe Reader could not open '132-171510.pdf' because it is either not a supported file type or the file has been damaged (for examplc, it was sent as an email attachment and wasn't correctly decoded)."
 Please help, it would be appreciated.  Thanks
 

View 5 Replies View Related

Table Census Data - Summary Column Not Working

Jul 4, 2014

I have a table census data containing the number of people having ages ranging from 0 to 120 years. Year 0 is in a column called F_0 and year 120 is in a column called F_120 with everything in between.

For example, when I create a script for the table the column for year 0 appears as: [F_0] [numeric](38, 8) NULL

I've already created 2 summary columns (people 0 to 18 years old and people 19 to 59 years old).

I follow the same methodology to create a summary table for people from 60 to 100 years old, but all the calculated values are NULL.

So the following is successful:
[Under_19] AS (((((((((((((((((([F_0]+[F_1])+[F_2])+[F_3])+[F_4])+[F_5])+[F_6])+[F_7])+[F_8])+[F_9])+[F_10])+[F_11])+[F_12])+[F_13])+[F_14])+[F_15])+[F_16])+[F_17])+[F_18]) PERSISTED,

But this is not:
[Over_60] AS (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((([F_60]+[F_61])+[F_62])+[F_63])+[F_64])+[F_65])+[F_66])+[F_67])+[F_68])+[F_69])+[F_70])+[F_71])+[F_72])+[F_73])+[F_74])+[F_75])+[F_76])+[F_77])+[F_78])+[F_79])+[F_80])+[F_81])+[F_82])+[F_83])+[F_84])+[F_85])+[F_86])+[F_87])+[F_88])+[F_89])+[F_90])+[F_91])+[F_92])+[F_93])+[F_94])+[F_95])+[F_96])+[F_97])+[F_98])+[F_99])+[F_100])+[F_101])+[F_102])+[F_103])+[F_104])+[F_105])+[F_106])+[F_107])+[F_108])+[F_109])+[F_110])+[F_111])+[F_112])+[F_113])+[F_114])+[F_115])+[F_116])+[F_117])+[F_118])+[F_119])+[F_120]) PERSISTED,

View 2 Replies View Related

Retrieve Data For Working Days Using Date Function

Aug 22, 2007

Hi
I would like to return data for working days only. This will need to exclude holidays.For eg In the Month of August we have 31 Days and every 1st day of 1st week is holiday.So my output should retrieve me 31-4=27 .
Any ideas?

Thanks...

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved