.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Web Q&A: Who Called the Script?, Concatenating Binary Files, and More

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

This month find out which part of an HTML document has called a script, how to concatenate binary files, find a node, reference one script from another, build a GUI database front end in Access, and compare XML files.

Edited by Nancy Michell

MSDN Magazine August 2003

View Complete Post

More Related Resource Links

run a bunch of sql script files using a stored procedure (without using xp_cmdshell)

Is this possible? Let me elaborate. I need to automate the execution of a bunch of sql script files (*.sql) placed by my users in a certain folder. One way I can do this is by using some kind of a script to loop thru the files in that folder and for each *.sql file found, launch a 'sqlcmd' command to execute the current script file using the -i option, ie, sqlcmd -S <server> -i <the current sql file in the loop> I tried doing this, but ran into a liitle bit of difficulty with the particular scripting language (JAVA). I was going to research this a bit more, but I also wanted to consider something that doesn't involve another script. So I was thinking about doing this using a stored procedure, but then I was wondering, how would I run a sql script file from sql server? The only way I can think of is still using sqlcmd, but then to use that within a stored procedure, I would need to turn on xp_cmdshell. Although I can do that, that invloves getting other people involved so I was wondering if there is way to do this without turning on xp_cmdshell.

Simplest way to open my script files?

Hi everybody, I usually save my scripts in the default place offered my SSMS (the location of that place is hard to find). However, if I open a script from a disk from different location, now when I need to open my saved scripts it looks in that folder and not in the folder where all my scripts are kept. How can I open the script from the right place if I don't remember where that folder is and I don't want to re-start SSMS? Thanks a lot in advance.  Premature optimization is the root of all evil in programming. (c) by Donald Knuth Naomi Nosonovsky, Sr. Programmer-Analyst My blog

Receive/Delete Multiple FTP Files based on condition using SCRIPT(VB) TASK

I am trying to receive and delete multiple FTP files from a remote FTP server using Script task Below is the code   Dim FTPConnMgr As ConnectionManager FTPConnMgr = Dts.Connections("FTP Connection Manager") Dim FTPClientConn As FtpClientConnection = New FtpClientConnection(FTPConnMgr.AcquireConnection(Nothing)) Dim FileTimeStampNew As String = "20100913021807" Dim remoteFileNames(0) As String remoteFileNames(0) = Dts.Variables("FtpRemoteDirectory").Value & "*" & FileTimeStampNew & ".*" 'Below hardcoded FileName works good. But the problem is there are lots of file in the FTP folder that I dont want to receive 'remoteFileNames(0) = Dts.Variables("FtpRemoteDirectory").Value & "Company_alpha_Full_20100913021807.xml" Dim localPath As String = Dts.Variables("FtpLocalDirectory").Value FTPClientConn.Connect() FTPClientConn.ReceiveFiles(remoteFileNames, localPath, False, False) FTPClientConn.Close() Dts.TaskResult = ScriptResults.Success End Sub End Class If i specifically mention the RemotefileNames this works fine but, when I say *.* it executes succefully but doesn't receives the file. Please advice how to receive multiple file based on a variable BR, AWM

Problem importing text files with binary zeros (0x00) via SSIS(SQL2005). It is all fine when using D

Hi.   There is a "text" file generated by mainframe and it has to be uploaded to SQL Server. I've reproduced the situation with smaller sample. Let the file look like following: A17     123.17  first row          BB29    493.19  second             ZZ3     18947.1 third row is longer And in hex format: 00:  41 31 37 20 20 20 20 20 ? 31 32 33 2E 31 37 20 20  A17     123.17  10:  66 69 72 73 74 20 72 6F ? 77 0D 0A 42 42 32 39 20  first row??BB29 20:  20 00 20 34 39 33 2E 31 ? 39 20 20 73 65 63 6F 6E     493.19  secon30:  64 0D 0A 5A 5A 33 20 20 ? 20 20 20 31 38 39 34 37  d??ZZ3     1894740:  2E 31 20 74 68 69 72 64 ? 20 72 6F 77 00 69 73 20  .1 third row is 50:  6C 6F 6E 67 65 72       ?                          longer          I wrote "text" in quotes because sctrictly it is not pure text file - non-text binary zeros (0x00) happen sometimes instead of spaces (0x20).   The table is: CREATE TABLE eng ( src varchar (512) )   When i upload this file into SQL2000 using DTS or Import wizard, the table contains: select src, substring(src,9,8), len(src) from eng <               src                ><substr>             <len> A17     123.17  first row           123.17                  25BB29                                493.19                  22ZZ3     18947.1 third row           18947.1                 35   As one can see, everything was importe

Missing/Required binary files on one Web-front-end after installed the CU aug 2010 hotfix?

Hi! I have installed the binary files for CU aug 2010 hotfix in a farm with two web-front-ends. In Central Administration you can see that on Web-front-end one (that also is hosting the Central Administration app) the binary files are missing but not on the second Web-Front-End. The installation went fine on both servers with the exception that I had to reboot the Web-Front-end one. When I try to run Psconfig to update my databases I get en error message like this in my command prompt. The upgrade command is invalid or a failure has been encountered. The server farm will not work with missing installs. Add "-cmd installcheck -noi nstallcheck" to the command-line to ignore this warning. The following is missing on web-front-end one: Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) Hotfix for Office (KB2352342) In the event log I get a lot of these errormessages too (EventID 3351): SQL database login for 'SharePoint_Config' on instance 'SqlAliasName' failed. Additional error information from SQL Server is included below. Login failed for user 'Domian\servername (one)$'. The thing is that the files is installed in the filesystems aswell as the dll files in the GAC on both servers. You can´t unistal

SSIS Script task that FTP's files


I could not find the exact details on how to create a SSIS script that would ftp files on these forums, so I am adding my code to help save time for anyone else that might be wanting to do something similar.  Here is the VB code for my script task to FTP files (hope this helps someone):

' Microsoft SQL Server Integration Services Script Task

' Write scripts using Microsoft Visual Basic

' The ScriptMain class is the entry point of the Script Task.

Imports System

Imports System.Data

Imports System.Math

Imports Microsoft.SqlServer.Dts.Runtime

Public Class ScriptMain

Public Sub Main()


'Create the connection to the ftp server

Help - Merging Two PDF files OR Merging Two Binary files


For some reason the last PDF file to be written to the "final document" is the only PDF File that is visible when the "final document" is open.  However, all of the bytes are accounted for in the file size...so for example: file1 = 60 bytes and file2 = 49 bytes.  The final document has 109 bytes but only contains file2 when viewed in the pdf viewer.  Any ideas?  What am I doing wrong? 


Public Sub getPDFsAndMerge()

        Dim myFinalDocumentPath As String = "C:\Temp\myFinalMergedPDFFile.pdf"
        Dim myFirstDocumentPath As String = "C:\Temp\fileOne.pdf"
        Dim mySecondDocumentPath As String = "C:\Temp\FileTwo.pdf"

        Dim fsFinalStream As New FileStream(myFinalDocumentPath, FileMode.Append, FileAccess.Write)

        Dim fsFirstStream As New FileStream(myFirstDocumentPath, FileMode.Open, FileAccess.Read)
        Dim fsSecondStream As New FileStream(mySecondDocumentPath, FileMode.Open, FileAccess.Read)

        Dim count As Integer = 1024

Reading large binary files



I currently have a WPF app that controls a printer. The app reads very large binary files (bitmap images, larger than 1 GB) and does some bit manupilation on them.

I am currently using a FileStream to read 100MB worth of bytes into a buffer (using FileStream.Read method). After that I start my method that does the bit manupilation on the image file and sends it out to the interface on a printer. When the buffer nears the end of the 100 MB length, say when there are few 100 bytes left to read in the buffer, I call the FileStream.Read method again to read in the next 100MB worth of data from the binary file. I specify the offset to read the binary file by using FileStream.Position method.

The problem I am facing is that when it finishes reading the 100MB buffer and goes to read the next 100MB worth of data, the printer pauses for the amount of time it takes to read the next 100MB and after that there is a pause for every line it prints in the image. It is like .NET framework or the compiler looses sync of doing things a particular because I have to read the next 100MB and then never recovers. The pause is about 2-3 seconds.

Everything is working great, the bit manipulation is correct, it reads the file correctly, the printer prints the file the way it is supposed to, except I want to avoid the pause.

Any suggestions....Can I use a back

Only Web services with a [ScriptService] attribute on the class definition can be called from script


I have created a web service.  When I check the service directly from it's web page it works correctly. Here's what the code looks like:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Configuration;
using System.Runtime.Serialization;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Text;
using Microsoft.SharePoint;
using System.Collections;

namespace MDA.WebParts.SPRolodex_Web_Service
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class SPRolodex_Web_Service : System.Web.Services.WebService

        public SPRolodex_Web_Service()


        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public bool ListExi

Best way to merge binary files


So I serialized a custom object I have through the BinaryFormatter's serialize method. I am unsure of how exactly it encodes it so I need some information here. I want add some Save/Load functionality so all I need to know is, what the best way to merge these custom files spit out after the Serialize method is done and what would be a good way to split them? I originally was thinking that I could just write to the main file how many files were merged but the thing is, I am not sure what is alright to use to write to these files. I just want to make sure that the files merged and split are exact clones of the way they were before the merge process.


SMO .net wrapper called from VB script


I have a C# class like below 


 public class SmoWrapperex

        public SmoWrapperex(){

        private Server smoServer;     

        public Server GetSMOServer(String ServerName, String UserName, String Password)
                ServerConnection srvConn = new ServerConnection(ServerName);
                srvConn.LoginSecure = false;

Clean Web.Config Files (VS 2010 and .NET 4.0 Series)

.NET 4 includes a new version of the CLR, and a new .NET 4 specific machine.config file (which is installed side-by-side with the one used by .NET 2, .NET 3 and .NET 3.5).

The new .NET 4 machine.config file now automatically registers all of the ASP.NET tag sections, handlers and modules that we've added over the years, including the functionality for:

.ASP.NET Dynamic Data
.ASP.NET Routing (which can now be used for both ASP.NET WebForms and ASP.NET MVC)
.ASP.NET Chart Control (which now ships built-into ASP.NET V4)
What this means is that when you create a new "Empty ASP.NET application" project in VS 2010, you'll find that the new default application-level web.config file is now clean and simple:

Rendering ASP.NET Script References into the Html Header

One thing that I've come to appreciate in control development in ASP.NET that use JavaScript is the ability to have more control over script and script include placement than ASP.NET provides natively. Specifically in ASP.NET you can use either the ClientScriptManager or ScriptManager to embed scripts and script references into pages via code.

SharePoint document migration challenges when migrating files and folders

There are several challenges when migrating documents to Microsoft SharePoint. While these challenges can be overcome, they are a real pain if the migration source, content and file systems are not SharePoint friendly.

Combine, minify and compress JavaScript files to load ASP.NET pages faster

Websites are getting more interactive these days and most of this interactivity comes from JavaScript. People are using different JavaScript libraries and frameworks to make their websites more interactive and user friendly.

PrintPocketCE Print Pocket Excel, Pocket Word and email files

Version 3.560 (May 15, 2009):

Important bug fix: a slight difference in how some devices create fonts was causing a few devices to have significantly longer print times for large print jobs.

Adjusted PocketJet printer paper feed commands

Other minor fixes and enhancements.

Version 3.559 (Mar 5, 2009):

Added support for Martel MCP78xx printers

Version 3.558 (Aug 20, 2008):

Added support for Martel MCP78xx printers

Version 3.557 (June 27, 2008):

Fixed error in Canon printer support

Fixed COM0 port selection

Version 3.556 (June 15, 2008):

Added support for Brother MW-260

Added support for Sato MB400

Version 3.555 (Aug 8, 2007):

Added support for Pentax RuggedJet 3 and RuggedJet 4 printers

Changed Epson TM-P60 support to maximum page width of 1200 dots

Version 3.551 (Aug 1, 2006):

Added Peripheral Nomad printer support

Version 3.550 (Mar 23, 2006):

Added Panasonic JT-H200PR printer support

Added Pocket Spectrum printer support

Fixed problem with WM5.0 "inverted image" problem
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend