Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Thursday, March 29, 2012

Description: String cannot have zero length. Event ID: 6003

When i add a new document to the queue, I receive this error in the event log. I used the example from the book in chapter 5 but i left out the scheduled piece. I am unable to find anything via searches on google etc. Your help would be appreciated. Thank you!

XSLT File

<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="notifications">

There is a new Test Document!

<xsl:apply-templates/>

</xsl:template>

<xsl:template match="notification">

Document Type: <xsl:value-of select="TypeName" />

Document Name: <xsl:value-of select="DocumentTitle" />

Document Category: <xsl:value-of select="CategoryName" />

<xsl:text>

</xsl:text>

</xsl:template>

</xsl:stylesheet>

Event log error:

Description: The assembly containing the content formatter could not be loaded.

EventParameters:

Instance Name: MyInstance 'Renamed for forum'

Application Name: Documents

Content Formatter Assembly Name:

Description: String cannot have zero length.

InstanceName: MyInstance 'Renamed for forum'

ApplicationName: Documents

Component: Distributor

ComponentDetails: DistributorName: MyDistributor 'Renamed for forum'

Thread: 4

ACF:

<ContentFormatter>

<ClassName>XsltFormatter</ClassName>

<Arguments>

<Argument>

<Name>XsltBaseDirectoryPath</Name>

<Value>%_ApplicationBaseDirectoryPath_%\Formatters</Value>

</Argument>

<Argument>

<Name>XsltFileName</Name>

<Value>NewDocumentByType.xslt</Value>

</Argument>

</Arguments>

</ContentFormatter>

ICF

<Application>

<ApplicationName>Documents</ApplicationName>

<BaseDirectoryPath>%_InstanceBaseDirectoryPath_%\Documents</BaseDirectoryPath>

<ApplicationDefinitionFilePath>ApplicationDefinition.xml</ApplicationDefinitionFilePath>

<Parameters>

<Parameter>

<Name>_NSServer_</Name>

<Value>%_NSServer_%</Value>

</Parameter>

<Parameter>

<Name>_SQLServer_</Name>

<Value>%_SQLServer_%</Value>

</Parameter>

<Parameter>

<Name>_ApplicationBaseDirectoryPath_</Name>

<Value>%_InstanceBaseDirectoryPath_%\Documents</Value>

</Parameter>

</Parameters>

</Application>

</Applications>

I fixed this by building a custom Formatter.

Tuesday, March 27, 2012

derived column transformation expression

Hi.

I am using the following expression to check if the first charcter of a string is not the letter "E" and if it is, strip it off by selecting the remainder of the string:

SUBSTRING([Derv.comno],1,1) == "E" ? SUBSTRING([Derv.comno],2,10) : [Derv.comno]

This is ok in 99.9% of cases, but ideally I would like to be able to check, and alter the string if the first charcter is anything but numeric

I had something like this in mind:

SUBSTRING([Derv.comno],1,1) != ("1","2","3") ? SUBSTRING([Derv.comno],2,10) : [Derv.comno]

but the syntax is incorrect.

Could you tell me if what I am attempting is actually possible, and if so, point me in the right direction regarding the syntax!

Thanks

CODEPOINT(@.[User::CCC]) >= 47 && CODEPOINT(@.[User::CCC]) <= 57 ? @.[User::CCC] : SUBSTRING(@.[User::CCC], 2, LEN(@.[User::CCC]) - 1)|||

Excellent, works a treat!

Thanks very much

sql

Derived Column Task Replace Quotes

How do you replace quotes in an expression

I mean for example if I needed to replace xx in a string with empty string then the following works: REPLACE(SelectedString, "xx","")

But the example I have needs to actually replace quote marks in a string with an empty string and REPLACE(SelectedString, " " ","") doesn't work. I tried guessing a few option like &QUOTE or &QTE or something...

Any ideas ?

Thanks

Richard

Got it !! :

REPLACE([Selected Closing],"\"","")

Sunday, March 25, 2012

Derived Column - DateTimeStamp From String (dd-mmm-yy)

I have come across something strange. I was wondering anyone else had the same problem or is it me?

I have a source file as shown below:
1,30-Feb-06,3,Test
2,20-Feb-06,5,Test1

Second column is defined as String(9) in the flat file source. Then I have a Derived Column between source and Trash destination. The Derived Column adds a new column to the datd flow. The expression is as shown below :
(DT_DBTIMESTAMP)(SUBSTRING(Col2,1,2) + "/" + SUBSTRING(Col2,4,3) + "/" + SUBSTRING(Col2,8,2))

The data is loading into the database successfully, where I was expecting it to fail. I placed a data viewer and saw the following result set.

Source (Col2) Derived Col
-
30-Feb-06 06/02/1930 00:00:00 - WRONG result set
20-Feb-06 20/02/2006 00:00:00 - RIGHT result set

Can anyone repeat this problem or am I missing something? I have got SP1 and Hotfix installed.

Thanks

Sutha

This one feels like an old friend - albeit an irritating old friend.

Briefly, this is a result of routines in oleaut. Really, the oleaut library is trying to be friendly and to cast your string to a valid date. Knowing that there are different formats out there such as yy-mm-dd and dd-mm-yy it "assumes" that you have a valid date in one of these formats and therefore - to hugely oversimplify - finds the format that enables it to perform a cast to a valid date.

Note that this behaviour has been around for a long time when using a non-US local (there are developers who believe it led to some slight misalignment of the pyramids) and many applications actually rely on the behaviour, so it is difficult to change after a long time.

I would suggest that if you are likely to have invalid dates of this particular nature, that you validate them using some code before applying the cast or conversion. Not a great solution, but effective.

Donald

Derived Column - Date Conversions?!?

It was my understanding earlier that -- it is mandatory to have a Derived Column for a DATE String in a Flat File
to be loaded properly into a table with "datetime" column type

However, i tried running my package with the Input Column as "DT_STR" and the Destination on the table is DATETIME.

Looks like the process went on fine.. Am i missing something here?

My Date Format from the source looks like -- "DD-MON-YY"

Regards
As long as it is in a format the DB understands, going from DT_STR to DateTime is an implicit conversion. So it's converting as it is inserted.

Thursday, March 22, 2012

Deployment Question, Connection string issue.

When we deploy applications, we have been using DSN's set up on the
users systems. Then in the sqlconnection string, we go "dsn = xyz". I
tried this with our new application, which is the first to be done
with ADO.net and I get the following run time problem:

"An exception 'System.ArgumentException' has occured in <Myapp>".
I do the run time debugging and it tells me: "Keyword not supported:
'dsn'.

For those who have migrated to .Net, how do you handle this issue? I
mean, we are going to distribute this application, and our users will
have different names for their servers, so how do we specify a data
source dynamically.

The way we have it for the moment is that we read the information from
a config file. But it seems like there must be a better way. What
happened to dsn?

Any help on this would greatly appreciated.
Thanks,
Ed Hawkes
olaamigoquepasa@.nospamplease-hotmail.comEd Hawkes (olaamigoquepasa@.hotmail.com) writes:
> When we deploy applications, we have been using DSN's set up on the
> users systems. Then in the sqlconnection string, we go "dsn = xyz". I
> tried this with our new application, which is the first to be done
> with ADO.net and I get the following run time problem:
> "An exception 'System.ArgumentException' has occured in <Myapp>".
> I do the run time debugging and it tells me: "Keyword not supported:
> 'dsn'.
> For those who have migrated to .Net, how do you handle this issue? I
> mean, we are going to distribute this application, and our users will
> have different names for their servers, so how do we specify a data
> source dynamically.
> The way we have it for the moment is that we read the information from
> a config file. But it seems like there must be a better way. What
> happened to dsn?

If you despearately need DSN, I would suppose you could use OleDb
client rather than SqlClient.

As for what happened, I guess DSN got of fashion, and I can't say that
I miss it. Our application - which is VB6 - once used DSN, but now you
can specify server and database on the login form (and the values are
saved in registry between invocations), which I very much like. Of course,
end users normally use the same server and database, and it's only
developers like me, who change all the time. But nevertheless, DSNs
is just one more thing that has to be configured, and which could buy
settings you did not expect.

IF you don't want to prompt your users, a config file seems like a
good way to go.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland Sommarskog <esquel@.sommarskog.se> wrote in message news:<Xns952AF310B27FBYazorman@.127.0.0.1>...
> Ed Hawkes (olaamigoquepasa@.hotmail.com) writes:
> > When we deploy applications, we have been using DSN's set up on the
> > users systems. Then in the sqlconnection string, we go "dsn = xyz". I
> > tried this with our new application, which is the first to be done
> > with ADO.net and I get the following run time problem:
> > "An exception 'System.ArgumentException' has occured in <Myapp>".
> > I do the run time debugging and it tells me: "Keyword not supported:
> > 'dsn'.
> > For those who have migrated to .Net, how do you handle this issue? I
> > mean, we are going to distribute this application, and our users will
> > have different names for their servers, so how do we specify a data
> > source dynamically.
> > The way we have it for the moment is that we read the information from
> > a config file. But it seems like there must be a better way. What
> > happened to dsn?
> If you despearately need DSN, I would suppose you could use OleDb
> client rather than SqlClient.
> As for what happened, I guess DSN got of fashion, and I can't say that
> I miss it. Our application - which is VB6 - once used DSN, but now you
> can specify server and database on the login form (and the values are
> saved in registry between invocations), which I very much like. Of course,
> end users normally use the same server and database, and it's only
> developers like me, who change all the time. But nevertheless, DSNs
> is just one more thing that has to be configured, and which could buy
> settings you did not expect.
> IF you don't want to prompt your users, a config file seems like a
> good way to go.

Erland,
much obliged! I really appreciate the response, and this will help
move our project along. Thanks again.
Cheers,
Ed Hawkessql

Deployment of SQLce - DATASOURCE issue

My connection string is simply

Data Source ="|DataDirectory|\Data\Test.sdf"; Password ="test";

and it runs just fine...

I did a simple publish (simple public, no checking for updates or anything)

When the public completes I run the install app. I get the following odd error during install:

************** Exception Text **************
The path is not valid. Check the directory for the database. [ Path = C:\Documents and Settings\jlibertor\Local Settings\Apps\2.0\Data\DZN9D6Y7.8E9\N0WB27KY.XZB\test..tion_b3b178185207c0b7_0001.0000_ef52a43c912d4680\Data\Data\Test.sdf ]

So... any ideas? thansk so much in advance!

have you tried;

Data Source ="|DataDirectory|\Test.sdf"; Password ="test";

Otherwise you can possibly override by using: AppDomain.Setdata

|||

OK I figured it out. ther were 2 reasons...

And if thsi helps anyone I'll past a few things:

You can set the DataDirectory using this code:

AppDomain.CurrentDomain.SetData("DataDirectory", System.AppDomain.CurrentDomain.BaseDirectory)

Place it in the application startup event.

Tip: you can't use the "My.StartupPath" in the event, and instead have to use "System.AppDomain.CurrentDomain.BaseDirectory"

ALSO

Don't forget that if you are getting this error you may not be publishing your .sdf file! (This my problem too) There are SEVERAL things you need to change in order to publich your file.

Tip: A good way to test if you are really publishign your .sdf file to check your publish package for it.

1-Set the properties of the .sdf file to "Content" and Output to "Copy Always"

2-In your Publish settings, look for yoru .sdf file. and force it to incluce.

Tip: After your user installs this once you don't want to publish it again. You'll want to change the above settings and supress this file (otherise you'll overwrite all of their hard-earned data )

Saturday, February 25, 2012

Deployed Application isn't connecting to SQL Server

When deploying my application that uses sql server it doesn't connect to the server.

I checked the connection string & it's ok the server instance is the same.

The computer name isn't the same & i use the .\SQLExpress as the data source.

I get an error saying 'sqlserver does not allow remote connections error 26 locating server / instance specified'.

Since computer name is changed, can you try to recreate the data source again? When creating a datasource, you can verify that if the datasource is ok to connect to the server.|||Another thing to look at is that if computer name is changed, the servername might not be valid. Can you run select @.@.servername to verify?|||

This link can help you.

http://blogs.msdn.com/sql_protocols/archive/2006/03/23/558651.aspx

|||

The connection string from the dataset that visual studio generated was wrong

it needed to be .\SQLExpress thanks to all for the help