Deploy ReportViewer 10 in Visual Studio 2010 to production site

.Net, SQL No Comments »

If you have developed a .Net 4 website in Visual Studio 10 that that uses a client reportviewer control, then you are likely to run into problems with running reportviewer on the production server. Here’s the steps to get it running:

  1. Install ReportViewer 10 on your production machine. Go to Microsoft Download Center and search for “Microsoft Report Viewer 2010”
    download and install to your production server
  2. publish website to production server
  3. on the development server go to
    [drive]:\Program Files\Microsoft Visual Studio 10.0\ReportViewer\
    and copy the following files to the “bin” folder of your live site:
    Microsoft.ReportViewer.Common.dll
    Microsoft.ReportViewer.WebForms.dll
  4. this is the tricky part, copying “Microsoft.ReportViewer.ProcessingObje
    ctModel.dll”
  5. on your production server open a Command Prompt window, then cd to [drive]:\Windows
  6. then dir /s Microsoft.ReportViewer.ProcessingObjectModel.dll to find the dll
  7. cd to assembly\gac_msil\microsoft.reportviewer.processingobjectmodel
    this path contained the 2 versions of the file:
    10.0.0.0__b03f5f7f11d50a3a
    9.0.0.0__b03f5f7f11d50a3a
    since I’m using VS2010, I need the version 10
  8. copy 10.0.0.0__b03f5f7f11d50a3a [drive]:\[path]\bin
  9. you will now see “Microsoft.ReportViewer.ProcessingObjectModel.dll” in your website’s bin folder, you’re good to go

Retrieve column names from a table as a string

SQL No Comments »

DECLARE @c varchar(4000), @t varchar(128)
SET @c = ”SET @t=’authors’
SELECT @c = @c + c.name + ‘, ‘ FROM syscolumns c INNER JOIN sysobjects o ON o.id = c.id WHERE o.name = @t ORDER BY colid
SELECT Substring(@c, 1, Datalength(@c) – 2)

(you can replace this value ‘, ‘ above with any delimiter you choose like ‘-‘ or ‘;’ then update the -2 in the last line with the number of characters in your delimiter)

T-SQL replace part of a field

SQL No Comments »

Replace a word inside the values of a column:
 UPDATE YourTableName SET ColumnAffected =REPLACE(ColumnAffected,’old value’,’new value’) WHERE (ColumnAffected LIKE N’%old value%’)

T-SQL use CASE statement

SQL No Comments »

Select with CASE (SQL only)
 SELECT title, price, Budget =
   CASE price
          WHEN price > 20.00 THEN ‘Expensive’
           WHEN price BETWEEN 10.00 AND 19.99 THEN ‘Moderate’
           WHEN price < 10.00 THEN ‘Inexpensive’
           ELSE ‘Unknown’
          END, FROM titles

Insert value into identity column in SQL

SQL No Comments »

before your “INSERT….” statement put this line:

SET IDENTITY_INSERT mytablename ON

Share data between stored procedures

SQL No Comments »

CREATE TABLE #tmp (…)
INSERT #tmp (…) EXEC @err = some_sp @par1, @par2 …

In your 2nd stored procedure, create a temporary table with the same column definitions of the output from 1st stored procedure, insert the output from 1st stored procedure into the temp table in the 2nd stored procedure and use it as you wish.

For more information…

Typed Datasets and Temp Tables

.Net, SQL No Comments »

The scenario: you have a stored procedure in SQL and a typed dataset in Visual Studio that references the stored procedure. In your stored procedure, you create a temporary table and fill it with data and use it as output. When you go to create the typed dataset, it does not recognize the columns that the stored procedure returns.

Solution: in Visual Studio, create you typed dataset and use the stored procedure as a source (even if it doesn’t recognize the columns). After it is done, right clck the xsd file in Solution Explorer and click “View Code”. You should get an xml representation of your dataset. Here is where you create your columns manually. You need to add the column definitions in 2 places:

  1. Find “TableAdapter”, under it look for “Mappings”, inside mappings you will add a node for each column like:
    <Mapping SourceColumn="CompanyName" DataSetColumn="CompanyName" />
  2. Find
    <xs:element name="dsGetCompany"…..
         <xs:element name="CompanyName" msprop:Generator_UserColumnName="CompanyName" ….

    you will add “<xs: element….” for each column you want to add. I found the best way is to copy these nodes from similar columns from another dataset.

For more information

Insert from Flat to SQL

SQL No Comments »

Step 1: Create a Destination table

Step 2: Create Schema File using Notepad
Save this file with “.FMT” Extension (for example: bcp.fmt)

Step 3
Create the following Store Procedure [Text_File_Bulk_Import] to import Text file data to Destination Table [Customer_Sample]

Execute the Store Procedure [Text_File_Bulk_Import]

link to full article

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in