Simple SQL Data Access Question

Oct 9, 2007

Hi,
I am developing an ASP.NET app that uses SQL Server 2005.
I have 1 single connection string to the database that is defined in my web.config.
In my backend VB code in the App_Data folder ( and so not related to any aspx page ) , i wish to access my database.

Here is the code I use:
        Dim query As New SqlDataSource
        query.ConnectionString = ConfigurationManager.ConnectionStrings("MainConnectionString").ConnectionString
        query.InsertCommand = "INSERT INTO myTable(data, time) VALUES (...)
        query.Insert()
All i want to is whether this is the correct and fastest way to access my database. Is it ??

Thanks for your help,
roxie
 

View 2 Replies


ADVERTISEMENT

Simple Web Access To SQL Server Data

Sep 21, 2006

I am looking at building some very simple web pages that attach to a SQL Server database. They will just display simple data from predefined views on the SQL Server.

A link to examples would be fantastic. I have done similar before to attach to data from access. Its the connection and data retrieval I need help with.

Thanks.
Mark.

View 4 Replies View Related

Simple Workgroup (Like Access) Use Of SQL Express ??

Feb 19, 2007

Hi all,

In the past if we wanted to provide an application with simple (multi-user) database facilities, we would use an Access mdb database which we could basically xcopy deploy to the client. Share the folder across the network and apart from the limitations of mdb databases it would work !!!

With all the advancements in databases ! we have moved on to SQL Express - touted as the thing to use and the replacement for MSDE and MDB databases. But hang on a minute !! It doesn't work like that ! You can't deploy Express like we used to with MDB databases - the default Express database doesn't allow multi-access ?? and if you can't xcopy deploy the Express database. The 'user Instance' thing is useless - basically every user gets their own copy of the database !!! How many developers asked Microsoft for that one!! It's crazy!!

We just need to copy our exe files and the mdf file share across a workgroup and bingo network version of our software - it's not brain surgery - Is it! We don't need mountains of security - we need (FIRST OF ALL) easy deployment.

Please tell me I've got it wrong and you can deploy a SQL Express based application without jumping thru hoops ????

Regards

Steve

View 10 Replies View Related

Data Access :: MS Access ADODB Connection To Stored Procedure - Cannot Retrieve Data

Sep 22, 2015

I'm trying to re-write my database to de-couple the interface (MS Access) from the SQL Backend.  As a result, I'm going to write a number of Stored Procedures to replace the MS Access code.  My first attempt worked on a small sample, however, trying to move this on to a real table hasn't worked (I've amended the SP and code to try and get it to work on 2 fields, rather than the full 20 plus).It works in SQL Management console (supply a Client ID, it returns all the client details), but does not return anything (recordset closed) when trying to access via VBA code.The Stored procedure is:-

USE [VMSProd]
GO
/****** Object: StoredProcedure [Clients].[vms_Get_Specified_Client] Script Date: 22/09/2015 16:29:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON

[code]....

View 4 Replies View Related

Data Access :: Management Studio To Access Data On Laptop?

Jun 30, 2015

I have a client who has SSMS installed on her laptop.  She is able to connect to the SQL server via SSMS in the office and query data on the server.

She needs to be out of site often and doesn't have internet access.  She asks if the data tables can be "backed up" or saved on her laptop, so she can look at them without worrying connecting to the server.  I am not sure if this can be achieved, as SSMS is built for accessing a server, not a desktop.  Myself never have this need.  If I really need it, I would go to Microsoft Access and create an ODBC connection to the datatables. But this client thinks that Microsoft Access is beneath her. 

View 4 Replies View Related

Data Access :: Data Import From Password Protected Access MDB

Jul 20, 2015

HowTo: Import data to MS SQL 2008 from password protected Access DB ?

View 2 Replies View Related

Data Access :: Server Rejected The Connection - Access To Selected Database Has Been Denied

Jun 10, 2015

I have recently upgraded to SQL2014 on Win2012. The Access front end program works fine.

But, previously created Excel reports with built in MS Queries now fail with the above error for users with MS 2013.  The queries still work for users still using MS 2007. 

I also cannot create any new queries and get the same error message. If I log on as myself on the domain to another PC with 2007 installed it works fine, so I don't think it is anything to do with AD groups or permissions.

View 6 Replies View Related

Data Access :: Insert Rows To MS Access 2013 Without Listing Column Names

Nov 12, 2015

We need to insert data/rows from a SQL Server 2014 database into MS Access database.  The problem is, there are so many columns (100+) in the table and there are so many insert transactions of this kind (from different tables) that it is not very easy to write the code in VB.NET that lists all column names.

Both the Access and SQL Server tables have the same number of columns and the equivalent data types, so inserting is not really the problem.  It's just that is there a way to do an insert statement in T-SQL that does not name all the columns?

View 3 Replies View Related

Database Schemas And This Statement Has Attempted To Access Data Whose Access Is Restricted By The Assembly.

Jul 14, 2005

Hello.

View 5 Replies View Related

Multi-user Access Through A Data-access Layer/remoting Server

Oct 30, 2007

Hi guys,

I've been developing desktop client-server and web apps and have used Access and SQL Server Standard most of the time.
I'm looking into using SQL CE, and had a few questions that I can't seem to get a clear picture on:

- The documentation for CE says that it supports 256 simultaneous connections and offers the Isolation levels, Transactions, Locking, etc with a 4GB DB. But most people say that CE is strictly a single-user DB and should not be used as a DB Server.
Could CE be extended for use as a multi-user DB Server by creating a custom server such as a .NET Remoting Server hosted through a Windows Service (or any other custom host) on a machine whereby the CE DB would run in-process with this server on the machine which would then be accessed by multiple users from multiple machines??
Clients PCs -> Server PC hosting Remoting Service -> ADO.NET -> SQL CE

- and further more can we use Enterprise Services (Serviced Components) to connect to SQL CE and further extend this model to offer a pure high-quality DB Server?
Clients PCs -> Server PC hosting Remoting Service -> Enterprise Services -> ADO.NET -> SQL CE

Seems quite doable to me, but I may be wrong..please let me know either ways

Thanks,
CP

View 3 Replies View Related

Data Access :: Server Does Not Exist Or Access Denied

Apr 22, 2015

When i am trying to start our hospital software based on SQL server 2000, it shows Following Error.Search Condition is not valid, (DBNETLIB) Connection Open (connect()).  SQL server does not exist or excess denied. Due to Fetch data.I run our software in Windows 8.1, while it smothly runs in previous version of Windows XP and 7.

View 2 Replies View Related

Simple Update Data

Jun 18, 2008

I am attempting to update contact data that is displayed in a form. Unfortunately the followiing code that runs off the button click event does not seem to work or I am misssing something to make it fire. I get no errors but the data does not get updated. What am I missing? Thanks.Private Sub btn_Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Submit.Click
Dim strConnection As StringDim cn As SqlConnection
Dim sql As String
strConnection = ConfigurationSettings.AppSettings("ConnectionString")cn = New SqlConnection(strConnection)
sql = "UPDATE vw_BS_IssuerContacts SET ContactLastName = @ContactLastName, ContactFirstName = @ContactFirstName, ContactTitle = @ContactTitle, ContactEmail = @ContactEmail, ContactPhone = @ContactPhone, Address1 = @Address1, Address2 = @Address2, Address3 = @Address3, Country = @Country, ZipCode = @zipCode, AccessLevel = @AccessLevel WHERE IssuerCode = @IssuerCode"Dim UpdateCommand As New SqlCommand(sql, cn)
UpdateCommand.Connection = cn
UpdateCommand.CommandText = sqlUpdateCommand.Parameters.Add(New SqlParameter("@IssuerCode", Lbl_IssuerCode.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@ContactLastName", txt_Lname.Text))UpdateCommand.Parameters.Add(New SqlParameter("@ContactFirstName", txt_Fname.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@ContactTitle", txt_title.Text))UpdateCommand.Parameters.Add(New SqlParameter("@ContactEmail", txt_Email.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@ContactPhone", txt_Phone.Text))UpdateCommand.Parameters.Add(New SqlParameter("@Address1", txt_Address.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@Address2", txt_Address2.Text))UpdateCommand.Parameters.Add(New SqlParameter("@Address3", txt_City.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@Country", txt_Country.Text))UpdateCommand.Parameters.Add(New SqlParameter("@ZipCode", txt_zipCode.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@AccessLevel", Lbl_currAccessLevel.Text))
'UpdateCommand.Parameters.Add(New SqlParameter("@AccessLevel", SqlDbType.Char, 2).Value = txt_CurrAccessLevelSelectedValue))UpdateCommand.Parameters.Add(New SqlParameter("@UserName", txt_Username.Text))
UpdateCommand.Parameters.Add(New SqlParameter("@infopw", txt_pw.Text))UpdateCommand.Parameters.Add(New SqlParameter("@Company", txt_IssName.Text))
'do the update
cn.Open()
UpdateCommand.ExecuteNonQuery()
 
cn.Close()
 
 
 End Sub
 
 

View 1 Replies View Related

Simple Q' About Data Type

Mar 31, 2004

hi,

when to use varchar and
when to use Nvarchar....

could any one tell please....

thanks

View 3 Replies View Related

Simple Data Transfer

Dec 27, 2007

Greetings all,
I have two databases and need to transfer some data from one to the other based on the "employee_Number".
"Table 1 and 2" both have a complete listing of employees but in "Table 1" certain columns are empty. I need to see if "Table 2" has got data in those columns and if yes import them to the "Table 1" based on the "Employee Number"
What is the simplest way to do this. both are on SQl server.
please Help

Thanks in advance........

View 3 Replies View Related

Simple Question On Importing Data

Feb 13, 2006

If I am trying to import data from an Access database into my tables via transact sql how and what are my first steps. I'm a newbie just trying to learn. Do I do via an insert statement and if so how do I do that. My SQL tables have no data in them and I would also have to make sure that can convert the datatypes from Access to SQL. Thanks in advance for anyhelp given.

View 4 Replies View Related

Simple Data Extraction From 2 Tables

Mar 22, 2007

So these are a couple different interpretations I've made of a statement that needs to return students name's with the OSOS field in the attendcode code column of the attendance table on todays date with an attendance.aperiod column equal to 4.


This first one returns no results at all when I should get about 7 rows or so.....

Select Student.name,
attendance.studentid,
attendance.attenddate,
attendance.aperiod,
attendance.attendcode
from Attendance, Student
where AttendDate >= DateAdd(Day, DateDiff(Day, 0, GetDate()), 0)
And AttendDate < DateAdd(Day, DateDiff(Day, 0, GetDate()), 0) + 1
And aperiod = '4'
And AttendCode = 'OSOS'
AND student.name = Attendance.studentid

This one is returning all of the names in the database 6 times each.

Select Student.name,
attendance.studentid,
attendance.attenddate,
attendance.aperiod,
attendance.attendcode
from Attendance, Student
where AttendDate >= DateAdd(Day, DateDiff(Day, 0, GetDate()), 0)
And AttendDate < DateAdd(Day, DateDiff(Day, 0, GetDate()), 0) + 1
And aperiod = '4'
And AttendCode = 'OSOS' order by name

I think something is messed up with my WHERE control but I cant figure it out... Any help is greatly appreciated!

View 4 Replies View Related

Need Help With A Simple Query - Grouping Data

Jul 30, 2007

Hello,

I have a table similar to the following (XYZ). I would like to write a select statement that will return the count of the unique items for each user that also happen to be less than 1 year old. The less than one year old part is rather easy dateadd(year, -1, getdate()), but I seem to be having a hard time figuring out how to get my desired result without using subselects. Any help greatly appreciated. Thanks in advance - Dan.

So my goal results are:

User Count
Dan 2
Dave 1


Table XYZ
ID User Item Value Date

1 Dan 1 20 5/5/2007

2 Dan 1 30 6/5/2007

3 Dave 2 25 6/1/2007

4 Dan 2 22 5/1/2007
5 Dan 3 23 5/1/2006



View 6 Replies View Related

Simple Data Flow Hangs

Jul 26, 2007

Hi

I have a simple data control task that has an OLE source and OLE target.

the source is a SQL query that returns 200m records this is then written straight out to a table. I have used a data flow task so that I can chunk up the inserts rather than using a INSERT INTO.....SELECT FROM.

I have ran it multiple times and it hangs once it reaches 18,961,020 records.

there is no locking on the database and I have even restarted the SQL instance to ensure that there was nothing else contending for resource.

I have changed gthe buffer size and rows per buffer to 100m and 100,000. Now it hangs before the 18.9m mark presumably becuase of the increased buffer size.

I notice that the SELECT statement continues to clock up io and cpu cycles but the BULK insert process has gone.

any ideas on where to start looking?

Thanks for your help

Marcus

View 16 Replies View Related

Exporting Simple English Data Into FoxPro 2.6 Dbf

Mar 9, 2008

Could any one help me in

Writing code/query to export simple English text data from MSSQL Sever2000 to FoxPro2.6 dbf


aamir_net68@yahoo.com

View 1 Replies View Related

Simple Question About Date Data Type

Aug 25, 2007

I want to create a procedure where nextvisitdate is a cloumn for date
so when I passed variable @nextvisitdate then which data type I have touse with it.

CREATE PROCEDURE sp_salesman_nextvisitdate

@salesman varchar (50),
@nextvisitdate date (50)

As

Select * from Entry Form

WHERE

@salesman = salesman
AND
@nextvisitdate = nextvisitdate


GO


You Have to Loss Many Times to Win Single Time

View 3 Replies View Related

(Simple) SQL Question Regarding P/F Keys And Inserting Data...

Jul 20, 2005

Hi, all:I'm a newbie trying to understand the concept of referential integrity anddealing with Primary and Foreign Keys. I'm sure mine is a simple problem...I've created 3 tables as follows:MemberTable-----1 Member ID (Primary key)2 Member Name3 etc...FoodsTable-----1 Food ID (Primary key)2 Food NameMemberFoods-----1 Member ID (Foreign key)2 Food ID (Foreign key)Now, I've just learned about referential integrity and all that, and this ismy first foray into creating primary/foreign keys, linking tables, etc. (soI'm assuming the above tables are fine). What I don't understand is this:if I have a (checkbox) form from which members can choose their favoritefoods, how do I insert that data? For example:Food Form-----Which of these are your favorite foods:1) Steak2) Chicken3) Potatoes4) etc...If I want to insert, let's say, 'Steak' and 'Chicken', do I have to first doa query on my Foods table to retrieve the Food ID's for Steak and Chicken,and then do an "insert" using those ID's into my MemberFoods table? (I amusing the actual Food Names (not ID's) as values on my form.) If so, cansomeone please share the SQL for retrieving and then inserting?I don' t know...maybe I'm overcomplicating the issue, but it just seems likea lot of extra work to maintain a "linking table" of foreign keys.Thanks for the help.

View 1 Replies View Related

Simple Data Dump Export To Excel?

May 21, 2007

Any ideas on how to export from excel and simply get rs to do a data dump, not pull over any of the formatting, just simple columns and rows of data?

View 1 Replies View Related

Ordering Columns In Data Flow (simple?)

Jan 6, 2007

Hello,
I am new to SSIS.
I am trying to write a simple package to export data from some SQL 2005 tables and into a flat file.
In my data flow, I am using the OLE-DB data source and then the flat file destination.

This all works fine except that I cant get the package to write the columns out in the order I want. Even when I drive the OLE-DB source by a query, they columns are getting written to the flat file in a different order than I want.

How is SSIS determining what order to write the columns in and, more importantly, how can I change it to do it in the order I want?
Please help if you can. As mentioned I am new to SSIS so please give clear+simple answers.

Thanks
Mgale1

View 5 Replies View Related

Simple Vb / Ssis Data Type Questions

Mar 27, 2007

I have a some raw data in a string that looks like



'1989'



I need that to become numeric 19.89



if I define a type double for rawAmount



and do this:



rawAmount = CInt(iRest.Substring(41, 4))

Row.amount2 = rawAmount / 100



where row.amount2 is a type double precision float from my script component task output, I get:



19.899999999999999



what output should i use in this data flow component to get 19.89.



thanks.





View 3 Replies View Related

Very Simple Getting Started Question About Formatting Data

Jan 2, 2008

Okay, I know this is a very simple question, but here it is.

I have a select statement that returns a value such as: 9902.7400000000.

In the select statement it just selecting Value. In the select statement, can I format the output to be with just two decimal places? I know I should know the answer to this and how to do it, but thank you for any help.

View 3 Replies View Related

Saving Data To A Database File Via Simple Form

Nov 2, 2007

Hi,
I am designing a site using Visual Web Developer, CSharp and Sql server Express.
One the contact page I want to put a form that allows users to enter details about
themselves. On clicking the button this will be stored in the database under a table
called subscribers. The form will have, name, address, telephone, email fields etc.
With the email addresses from the visitors I want to be able to keep them in
a newsletter section or similar which is automated so they recevie emails from time to time
Could somebody suggest a tutorial which shows how to complete this process
using c sharp and sql.
 
Thanks for you time
 
Prontonet
 

View 2 Replies View Related

Simple IF Or CASE Statement In Data Flow Transformation

May 11, 2007

Using SSIS to import from Excel to SQL Server.

In Excel they are showing Sale as -ve quantity and purchase as +ve quantity.

The database has quantity always as +ve figure and a separate column "isPurchase" set to true or false depending on whether purchase or sale.



So I need Derived Column to return a bolean (or int) depending whether quantity is positive or negative. I tried each of the following in the Expression but all of them were invalid expressions.

CASE WHEN [TotalQuantity] > 0 THEN 0 ELSE 1 END

If [TotalQuantity] > 0 THEN 1 ELSE 0 END

IIF ([TotalQuantity] > 0, 1,0)



Can anyone help me with correct syntax, or correct Data Flow Transformation if Derived column is wrong.



Thanks



Richard

View 3 Replies View Related

Implementing A Simple Data Dictionary Via Extented Properties

Jun 25, 2007

Hi,



I'm thinking of implementing a rudimentary Data Dictionary for a database using extended properties to store table and column descriptions.

Does having this information for every table and column in a database (200 tables; 2000 columns) cause any (negative) impact on database performance? I'm guessing it shouldn't but want to make sure before implementing this in the production environment.



Thanks,

Smitha

View 3 Replies View Related

Simple Simple Linking Tables & Perform Calculation

Mar 22, 2007

found it

View 3 Replies View Related

Shouldn't This Be Simple? Sybase To Oracle Data Transfer Task

May 28, 2007

I'd like to transfer some records between the following 2 tables. Surely this should be a no-brainer - what am i missing that is making this so impenetrable?

I am currently: Hoping someone can help me get here: (this is my first time of using SSIS btw).



here is the source table (MS Sql Server 2005, SP 2)



CREATE TABLE [dbo].[imagine_divs](

[div_mnemonic] [nvarchar](11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[div_date] [int] NULL,

[div_amount] [float] NULL,

[div_status] [nvarchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[div_curr_mnem] [nvarchar](11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[div_upd_date] [int] NULL,

[div_payment_date] [int] NULL

) ON [PRIMARY]



here is the target table (Oracle 9i)



CREATE TABLE myschema.imagine_divs

(div_mnemonic NVARCHAR2(11),

div_date NUMBER(*,0),

div_amount NUMBER(20,5),

div_status NVARCHAR2(16),

div_curr_mnem NVARCHAR2(11),

div_upd_date NUMBER(*,0),

div_payment_date NUMBER(*,0))

/



I used the SSIS Import and Export wizard to copy data between the two tables, and attempted to execute it. I use Sql Native Provider on source, and Native Ole DBOracle Provider for OLEDB. however, I get an error:



[Destination - IMAGINE_DIVS [37]] Error: An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "OraOLEDB" Hresult: 0x80004005 Description: "ORA-12571: TNSacket writer failure".



I notice that the wizard has created a data flow task with 3 steps: source - imagine_divs, Destination - IMAGINE_DIVS and "data conversion 1".



Data Conversion 1 seems to be taking my source nvarchar columns and converting them to DT_STR with twice the size (for example div_mnemonic become DT_STR, size: 22).



If I change the mappings in the OLE DB Destination Editor, such that only the numeric and date-typed columns are included in the transfer, it works fine.



If I include any string-typed column in the destination editor mappings, I get the TNS Packet Writer error. If I remove the Data Conversion step and connection teh source and destination tasks directly, i get validation errors saying that:



Error 2 Validation error. Data Flow Task: OLE DB Destination [294]: Columns "div_mnemonic" and "DIV_MNEMONIC" cannot convert between unicode and non-unicode string data types. Package4.dtsx 0 0


this is despite the fact that everything is unicode here (right?)



what in the world is going on?

View 4 Replies View Related

Simple Copy Table Data Fails After 7973680 Rows

Nov 18, 2005

This is the error I get with a simple Data Reader Source (SELECT * FROM A) to SQL Server Destination copy between identical tables from a linked to a local server:

View 6 Replies View Related

How To Programmatically Set Column Mappings Of A Simple Data Flow Task?

Sep 4, 2007

Has anyone done this? I can't find anything in the documentation
that describes this. The closest I get is to the InnerObject property
of the TaskHost class. There is an example of programming a bulk
insert task. But I can't find anything on programmatically setting
the column mappings (source to dest) of a simple data flow task. Any
help is appreciated!

View 7 Replies View Related

Simple Custom Data Flow Transformation Doesn't Produce Any Output

Aug 30, 2006

I've built a simple custom data flow transformation component following the Hands On Lab (http://www.microsoft.com/downloads/details.aspx?familyid=1C2A7DD2-3EC3-4641-9407-A5A337BEA7D3&displaylang=en) and the Books Online (ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.SQL.v2005.en/dtsref9/html/adc70cc5-f79c-4bb6-8387-f0f2cdfaad11.htm and ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.SQL.v2005.en/dtsref9/html/b694d21f-9919-402d-9192-666c6449b0b7.htm).

All it is supposed to do is create an output column and set its value to the result of calling a web service method (the transformation is synchronous). Everything seems fine, but when I run the data flow task that contains it, it doesn't generate any output. The Visual Studio debugger displays it as yellow, with 1,385 rows going into it, but the data viewer attached to its output is empty. The output metadata looks just like I expect: all of my input columns plus the new column, correctly typed. No validation or run-time warnings or errors are reported.

I'll include the entire C# file below, which only overrrides the ProvideComponentProperties, Validate, PreExecute, ProcessInput, and PostExecute methods of the parent PipelineComponent class.

Since this is effectively a specialization of the DerivedColumn transformation, could I inherit from the class that implements the DC component instead of PipelineComponent? How do I even find out what that class is?

Thanks! Here's the code:
using System;
// using System.Collections.Generic;
// using System.Text;

using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

namespace CustomComponents
{
[DtsPipelineComponent(DisplayName = "GID", ComponentType = ComponentType.Transform)]
public class GidComponent : PipelineComponent
{
///
/// Column indexes for faster processing.
///
private int[] inputColumnBufferIndex;
private int outputColumnBufferIndex;

///
/// The GID web service.
///
private GID.WS_PDF.PDFProcessService gidService = null;

///
/// Called to initialize/reset the component.
///
public override void ProvideComponentProperties()
{
base.ProvideComponentProperties();
// Remove any existing metadata:
base.RemoveAllInputsOutputsAndCustomProperties();
// Create the input and the output:
IDTSInput90 input = this.ComponentMetaData.InputCollection.New();
input.Name = "Input";
IDTSOutput90 output = this.ComponentMetaData.OutputCollection.New();
output.Name = "Output";
// The output is synchronous with the input:
output.SynchronousInputID = input.ID;
// Create the GID output column (16-character Unicode string):
IDTSOutputColumn90 outputColumn = output.OutputColumnCollection.New();
outputColumn.Name = "GID";
outputColumn.SetDataTypeProperties(Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_WSTR, 16, 0, 0, 0);
}

///
/// Only 1 input and 1 output with 1 column is supported.
///
///
public override DTSValidationStatus Validate()
{
bool cancel = false;
DTSValidationStatus status = base.Validate();
if (status == DTSValidationStatus.VS_ISVALID)
{
// The input and output are created above and should be exactly as specified
// (unless someone manually edited the persisted XML):
if (ComponentMetaData.InputCollection.Count != 1)
{
this.ComponentMetaData.FireError(0, ComponentMetaData.Name,
"Invalid metadata: component accepts 1 Input.",
string.Empty, 0, out cancel);
status = DTSValidationStatus.VS_ISCORRUPT;
}
else if (ComponentMetaData.OutputCollection.Count != 1)
{
this.ComponentMetaData.FireError(0, ComponentMetaData.Name,
"Invalid metadata: component provides 1 Output.",
string.Empty, 0, out cancel);
status = DTSValidationStatus.VS_ISCORRUPT;
}
else if (ComponentMetaData.OutputCollection[0].OutputColumnCollection.Count != 1)
{
this.ComponentMetaData.FireError(0, ComponentMetaData.Name,
"Invalid metadata: component Output must be 1 column.",
string.Empty, 0, out cancel);
status = DTSValidationStatus.VS_ISCORRUPT;
}
// And the output column should be a Unicode string:
else if ((ComponentMetaData.OutputCollection[0].OutputColumnCollection[0].DataType != DataType.DT_WSTR) ||
(ComponentMetaData.OutputCollection[0].OutputColumnCollection[0].Length != 16))
{
ComponentMetaData.FireError(0, ComponentMetaData.Name,
"Invalid metadata: component Output column data type must be (DT_WSTR, 16).",
string.Empty, 0, out cancel);
status = DTSValidationStatus.VS_ISBROKEN;
}
}
return status;
}

///
/// Called before executing, to cache the buffer column indexes.
///
public override void PreExecute()
{
base.PreExecute();
// Get the index of each input column in the buffer:
IDTSInput90 input = ComponentMetaData.InputCollection[0];
inputColumnBufferIndex = new int[input.InputColumnCollection.Count];
for (int col = 0; col < input.InputColumnCollection.Count; col++)
{
inputColumnBufferIndex[col] = BufferManager.FindColumnByLineageID(input.Buffer, input.InputColumnCollection[col].LineageID);
}
// Get the index of the output column in the buffer:
IDTSOutput90 output = ComponentMetaData.OutputCollection[0];
outputColumnBufferIndex = BufferManager.FindColumnByLineageID(input.Buffer, output.OutputColumnCollection[0].LineageID);
// Get the GID web service:
gidService = new GID.WS_PDF.PDFProcessService();
}

///
/// Called to process the buffer:
/// Get a new GID and save it in the output column.
///
///
///
public override void ProcessInput(int inputID, PipelineBuffer buffer)
{
if (! buffer.EndOfRowset)
{
try
{
while (buffer.NextRow())
{
// Set the output column value to a new GID:
buffer.SetString(outputColumnBufferIndex, gidService.getGID());
}
}
catch (System.Exception ex)
{
bool cancel = false;
ComponentMetaData.FireError(0, ComponentMetaData.Name, ex.Message, string.Empty, 0, out cancel);
throw new Exception("Could not process input buffer.");
}
}
}

///
/// Called after executing, to clean up.
///
public override void PostExecute()
{
base.PostExecute();
// Resign from the GID service:
gidService = null;
}
}
}

View 1 Replies View Related







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