Showing posts with label text. Show all posts
Showing posts with label text. Show all posts

Thursday, March 22, 2012

( ) problem

hi all,

i have some problem in my web application, am using vb.net

i have a text box and an add button, when the user click on the add button, whatever written in the textbox stores on my sql database

the problem is whenever there is a ( ' ) character in the text, it send me error

i know why this problem occure but i dont know what is the reqired code for it

this is the code:

sql.commandtext = "INSERT INTO myDB (Ques) VALUES ('" & txtQues.text & "')

what is the solution?

The answer is very simple in C# those are literals and in ANSI SQL they are Delimited Identifiers per ANSI SQL 92 and SQL Server is compliant so try the link below on how to enable it and handle it correctly. Hope this helps.

http://msdn2.microsoft.com/en-us/library/ms176027.aspx

|||

If you think about it, you are putting together the string before it gets sent to SQL Server. So, if your value has a single quote it, your insert would look something like:

INSERT INTO myDB (Ques) VALUES ('myvalue's')

This is confusing. The string seems to end after the 'e', when you really want it to end after the 's'. As said, SQL Server is taking that literally. If you're going to build the insert statement this way (as opposed to using a stored procedure), you need to replace single quotes with two single quotes (not a double quote - literally two single quotes).

txtQues.Text.Replace("'", "''")

The string passed to the database will be:

INSERT INTO myDB (Ques) VALUES ('myvalue''s')

which the database will interpret correctly.

|||Parameterized queries.|||thanks alot... for your helpBig Smile

Tuesday, March 20, 2012

"Unicode" in Flat File Connection Manager

Hello,

Does anybody know, how to load unicode text file using Flat File Source Task?

I set "unicode" option on the general tab of the Flat File Conn. Manager.

(my text file is comma delimited, the default row delimiter is {CR}{LF})

but on the Column tab I see only one row in one column (I have several rows and columns in the flat file).

How to see them all ?

I appreciate any help !

Anna

Hi Anna,

Do you know if your file is encoded as UTF16 or UTF8. If it is UTF8 uncheck the Unicode flag ans select an appropriate code page for UTF8.

Thanks,

Bob

|||

Hello Bob,

I did it - I set Code page to 65001.

It works now.

Thank you!

Anna

Saturday, February 25, 2012

"Command text was not set for the command object" Error

Hi. I am writing a program in C# to migrate data from a Foxpro database to an SQL Server 2005 Express database. The package is being created programmatically. I am creating a separate data flow for each Foxpro table. It seems to be doing it ok but I am getting the following error message at the package validation stage:

Description: An OLE DB Error has occured. Error code: 0x80040E0C.

An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E0C Description: "Command text was not set for the command object".

.........

Description: "component "OLE DB Destination" (22)" failed validation and returned validation status "VS_ISBROKEN".

This is the first time I am writing such code and I there must be something I am not doing correct but can't seem to figure it out. Any help will be highly appreciated. My code is as below:

private bool BuildPackage()

{

// Create the package object

oPackage = new Package();

// Create connections for the Foxpro and SQL Server data

Connections oPkgConns = oPackage.Connections;

// Foxpro Connection

ConnectionManager oFoxConn = oPkgConns.Add("OLEDB");

oFoxConn.ConnectionString = sSourceConnString; // Created elsewhere

oFoxConn.Name = "SourceConnectionOLEDB";

oFoxConn.Description = "OLEDB Connection For Foxpro Database";

// SQL Server Connection

ConnectionManager oSQLConn = oPkgConns.Add("OLEDB");

oSQLConn.ConnectionString = sTargetConnString; // Created elsewhere

oSQLConn.Name = "DestinationConnectionOLEDB";

oSQLConn.Description = "OLEDB Connection For SQL Server Database";

// Add Prepare SQL Task

Executable exSQLTask = oPackage.Executables.Add("STOCK:SQLTask");

TaskHost thSQLTask = exSQLTask as TaskHost;

thSQLTask.Properties["Connection"].SetValue(thSQLTask, "oSQLConn");

thSQLTask.Properties["DelayValidation"].SetValue(thSQLTask, true);

thSQLTask.Properties["ResultSetType"].SetValue(thSQLTask, ResultSetType.ResultSetType_None);

thSQLTask.Properties["SqlStatementSource"].SetValue(thSQLTask, @."C:\LPFMigrate\LPF_Script.sql");

thSQLTask.Properties["SqlStatementSourceType"].SetValue(thSQLTask, SqlStatementSourceType.FileConnection);

thSQLTask.FailPackageOnFailure = true;

// Add Data Flow Tasks. Create a separate task for each table.

// Get a list of tables from the source folder

arFiles = Directory.GetFileSystemEntries(sLPFDataFolder, "*.DBF");

for (iCount = 0; iCount <= arFiles.GetUpperBound(0); iCount++)

{

// Get the name of the file from the array

sDataFile = Path.GetFileName(arFiles[iCount].ToString());

sDataFile = sDataFile.Substring(0, sDataFile.Length - 4);

oDataFlow = ((TaskHost)oPackage.Executables.Add("DTS.Pipeline.1")).InnerObject as MainPipe;

oDataFlow.AutoGenerateIDForNewObjects = true;

// Create the source component

IDTSComponentMetaData90 oSource = oDataFlow.ComponentMetaDataCollection.New();

oSource.Name = (sDataFile + "Src");

oSource.ComponentClassID = "DTSAdapter.OLEDBSource.1";

// Get the design time instance of the component and initialize the component

CManagedComponentWrapper srcDesignTime = oSource.Instantiate();

srcDesignTime.ProvideComponentProperties();

// Add the connection manager

if (oSource.RuntimeConnectionCollection.Count > 0)

{

oSource.RuntimeConnectionCollection[0].ConnectionManagerID = oFoxConn.ID;

oSource.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(oFoxConn);

}

// Set Custom Properties

srcDesignTime.SetComponentProperty("AccessMode", 0);

srcDesignTime.SetComponentProperty("AlwaysUseDefaultCodePage", true);

srcDesignTime.SetComponentProperty("OpenRowset", sDataFile);

// Re-initialize metadata

srcDesignTime.AcquireConnections(null);

srcDesignTime.ReinitializeMetaData();

srcDesignTime.ReleaseConnections();

// Create Destination component

IDTSComponentMetaData90 oDestination = oDataFlow.ComponentMetaDataCollection.New();

oDestination.Name = (sDataFile + "Dest");

oDestination.ComponentClassID = "DTSAdapter.OLEDBDestination.1";

// Get the design time instance of the component and initialize the component

CManagedComponentWrapper destDesignTime = oDestination.Instantiate();

destDesignTime.ProvideComponentProperties();

// Add the connection manager

if (oDestination.RuntimeConnectionCollection.Count > 0)

{

oDestination.RuntimeConnectionCollection[0].ConnectionManagerID = oSQLConn.ID;

oDestination.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.ToConnectionManager90(oSQLConn);

}

// Set custom properties

destDesignTime.SetComponentProperty("AccessMode", 2);

destDesignTime.SetComponentProperty("AlwaysUseDefaultCodePage", false);

destDesignTime.SetComponentProperty("OpenRowset", "[dbo].[" + sDataFile + "]");

// Create the path to link the source and destination components of the dataflow

IDTSPath90 dfPath = oDataFlow.PathCollection.New();

dfPath.AttachPathAndPropagateNotifications(oSource.OutputCollection[0], oDestination.InputCollection[0]);

// Iterate through the inputs of the component.

foreach (IDTSInput90 input in oDestination.InputCollection)

{

// Get the virtual input column collection

IDTSVirtualInput90 vInput = input.GetVirtualInput();

// Iterate through the column collection

foreach (IDTSVirtualInputColumn90 vColumn in vInput.VirtualInputColumnCollection)

{

// Call the SetUsageType method of the design time instance of the component.

destDesignTime.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READWRITE);

}

//Map external metadata to the inputcolumn

foreach (IDTSInputColumn90 inputColumn in input.InputColumnCollection)

{

IDTSExternalMetadataColumn90 externalColumn = input.ExternalMetadataColumnCollection.New();

externalColumn.Name = inputColumn.Name;

externalColumn.Precision = inputColumn.Precision;

externalColumn.Length = inputColumn.Length;

externalColumn.DataType = inputColumn.DataType;

externalColumn.Scale = inputColumn.Scale;

// Map the external column to the input column.

inputColumn.ExternalMetadataColumnID = externalColumn.ID;

}

}

}

// Add precedence constraints to the package executables

PrecedenceConstraint pcTasks = oPackage.PrecedenceConstraints.Add((Executable)thSQLTask, oPackage.Executables[0]);

pcTasks.Value = DTSExecResult.Success;

for (iCount = 1; iCount <= (oPackage.Executables.Count - 1); iCount++)

{

pcTasks = oPackage.PrecedenceConstraints.Add(oPackage.Executables[iCount - 1], oPackage.Executables[iCount]);

pcTasks.Value = DTSExecResult.Success;

}

// Validate the package

DTSExecResult eResult = oPackage.Validate(oPkgConns, null, null, null);

// Check if the package was successfully executed

if (eResult.Equals(DTSExecResult.Canceled) || eResult.Equals(DTSExecResult.Failure))

{

string sErrorMessage = "";

foreach (DtsError pkgError in oPackage.Errors)

{

sErrorMessage = sErrorMessage + "Description: " + pkgError.Description + "\n";

sErrorMessage = sErrorMessage + "HelpContext: " + pkgError.HelpContext + "\n";

sErrorMessage = sErrorMessage + "HelpFile: " + pkgError.HelpFile + "\n";

sErrorMessage = sErrorMessage + "IDOfInterfaceWithError: " + pkgError.IDOfInterfaceWithError + "\n";

sErrorMessage = sErrorMessage + "Source: " + pkgError.Source + "\n";

sErrorMessage = sErrorMessage + "Subcomponent: " + pkgError.SubComponent + "\n";

sErrorMessage = sErrorMessage + "Timestamp: " + pkgError.TimeStamp + "\n";

sErrorMessage = sErrorMessage + "ErrorCode: " + pkgError.ErrorCode;

}

MessageBox.Show("The DTS package was not built successfully because of the following error(s):\n\n" + sErrorMessage, "Package Builder", MessageBoxButtons.OK, MessageBoxIcon.Information);

return false;

}

// return a successful result

return true;

}

So the OLE-DB Destination is not happy and I cannot see anything obvious. A better way to debug this would be to just add a Save method before validation to save your package to disk. You can then open it in Visual Studio/BIDS, and enjoy the full GUI experience to help find the problem. I've found this method very useful for just checking packages when building programmatically.

|||

I have inserted code to save the package just before the validation but it throws an exception. And I don't find the help in MSDN very useful!! I want to save the package in the folder C:\LPFMigrate and call it Package.dtsx. The code is as follows:

oApp = new Microsoft.SqlServer.Dts.Runtime.Application();

oApp.SaveToDtsServer(oPackage, null, @."C:\LPFMigrate\Package", "MARS");

Any idea why an exception is being thrown? The exception message is:

The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))

Sunday, February 19, 2012

<Long Text> errors on a 'text char(16)' column

Our SQL Server database is being utilized by many Applix/iHelpdesk
forms. On a cloumn with a 'text char(16)' datatype, we recently found
2 <Long Text> errors on a table. The Applix developers said their
application was locked up. My DBArtisan can disply only two records.
The third row showed a <Long Text> error in the Enterprise Manager.
Was my DBArtisan also locked up?
What kinds of Applix data format caused the the <Long Test> error?
How to solve this problem?
TIA.
JeffreyThat's not an error; that's Enterprise Manager not displaying TEXT/NTEXT
properly. Use a better tool (e.g. Query Analyzer) and that problem goes
away.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
--
"Jeffrey" <cjeffwang@.yahoo.com> wrote in message
news:c61d4674.0411221528.487ebc2@.posting.google.com...
> Our SQL Server database is being utilized by many Applix/iHelpdesk
> forms. On a cloumn with a 'text char(16)' datatype, we recently found
> 2 <Long Text> errors on a table. The Applix developers said their
> application was locked up. My DBArtisan can disply only two records.
> The third row showed a <Long Text> error in the Enterprise Manager.
> Was my DBArtisan also locked up?
> What kinds of Applix data format caused the the <Long Test> error?
> How to solve this problem?
> TIA.
> Jeffrey

<Long Text> errors on a 'text char(16)' column

Our SQL Server database is being utilized by many Applix/iHelpdesk
forms. On a cloumn with a 'text char(16)' datatype, we recently found
2 <Long Text> errors on a table. The Applix developers said their
application was locked up. My DBArtisan can disply only two records.
The third row showed a <Long Text> error in the Enterprise Manager.
Was my DBArtisan also locked up?
What kinds of Applix data format caused the the <Long Test> error?
How to solve this problem?
TIA.
Jeffrey
That's not an error; that's Enterprise Manager not displaying TEXT/NTEXT
properly. Use a better tool (e.g. Query Analyzer) and that problem goes
away.
Adam Machanic
SQL Server MVP
http://www.sqljunkies.com/weblog/amachanic
"Jeffrey" <cjeffwang@.yahoo.com> wrote in message
news:c61d4674.0411221528.487ebc2@.posting.google.co m...
> Our SQL Server database is being utilized by many Applix/iHelpdesk
> forms. On a cloumn with a 'text char(16)' datatype, we recently found
> 2 <Long Text> errors on a table. The Applix developers said their
> application was locked up. My DBArtisan can disply only two records.
> The third row showed a <Long Text> error in the Enterprise Manager.
> Was my DBArtisan also locked up?
> What kinds of Applix data format caused the the <Long Test> error?
> How to solve this problem?
> TIA.
> Jeffrey

<Long Text> errors on a 'text char(16)' column

Our SQL Server database is being utilized by many Applix/iHelpdesk
forms. On a cloumn with a 'text char(16)' datatype, we recently found
2 <Long Text> errors on a table. The Applix developers said their
application was locked up. My DBArtisan can disply only two records.
The third row showed a <Long Text> error in the Enterprise Manager.
Was my DBArtisan also locked up?
What kinds of Applix data format caused the the <Long Test> error?
How to solve this problem?
TIA.
Jeffrey
Can you script out this table?
There is no text char(16) data type. There is a text data type and a char
datatype, but no text char(16) data type.
"Jeffrey" <cjeffwang@.yahoo.com> wrote in message
news:c61d4674.0411221515.474c4231@.posting.google.c om...
> Our SQL Server database is being utilized by many Applix/iHelpdesk
> forms. On a cloumn with a 'text char(16)' datatype, we recently found
> 2 <Long Text> errors on a table. The Applix developers said their
> application was locked up. My DBArtisan can disply only two records.
> The third row showed a <Long Text> error in the Enterprise Manager.
> Was my DBArtisan also locked up?
> What kinds of Applix data format caused the the <Long Test> error?
> How to solve this problem?
> TIA.
> Jeffrey

Thursday, February 16, 2012

<Long Text> display on 'text' datatype (16-byte pointer) column

Our SQL Server database is being utilized by many Applix/iHelpdesk
devlopers and users.
On a cloumn with a 'text'datatype (16-byte pointer), we recently were
informed by the developers that their application was locked up. In
Enterprise Manager, I found 2 <Long Text> displays on a table. My
DBArtisan can disply only two records. The third row showed a <Long
Text> in the Enterprise Manager.
Was my DBArtisan also locked up?
How to solve this problem from Applix side?
TIA.
Jeffrey
Jeffrey,
Yes, what you have in your table is a column defined with the TEXT datatype
that shows up as a 16-byte textpointer. Most likely the cause is a implied
UPDATE statement is being held on the TEXT data by you application Applix
while your application is open and this is causing blocking or "locking up"
the data from access by other applications. You can use SQL Profiler to
confirm exactly what your application is doing and then alter the code.
Regards,
John
"Jeffrey" <cjeffwang@.gmail.com> wrote in message
news:bb2899d2.0411222006.571cfacb@.posting.google.c om...
> Our SQL Server database is being utilized by many Applix/iHelpdesk
> devlopers and users.
> On a cloumn with a 'text'datatype (16-byte pointer), we recently were
> informed by the developers that their application was locked up. In
> Enterprise Manager, I found 2 <Long Text> displays on a table. My
> DBArtisan can disply only two records. The third row showed a <Long
> Text> in the Enterprise Manager.
> Was my DBArtisan also locked up?
> How to solve this problem from Applix side?
> TIA.
> Jeffrey

<<< I couldnt backup my SQL Databases >>> !!!

here is Codes
////////////////// textBox1.Text = ADEMTEKEREK (server
computer's name)
FileInfo SourceFile1=new FileInfo("\\\\" + textBox1.Text +
"\\c\\Program Files\\Microsoft SQL
Server\\MSSQL\\Data\\MYDATABASE_Data.Mdf");
FileInfo SourceFile2=new FileInfo("\\\\" + textBox1.Text +
"\\c\\Program Files\\Microsoft SQL
Server\\MSSQL\\Data\\MYDATABASE_Log.Ldf");
SourceFile1.CopyTo("D:\\",true);
SourceFile2.CopyTo("D:\\",true);
...and when i start my form, there is this Error Message
Could not find file"\\ADEMTEKEREK\c\Program Files\Microsoft SQL
Server\MSSQL\Data\MYDATABASE_Data.Mdf"
WHAT CAN I DO...'?
thnks for now....< wrote on 6 Apr 2006 02:02:09 -0700:

> here is Codes
> ////////////////// textBox1.Text = ADEMTEKEREK (server
> computer's name)
> FileInfo SourceFile1=new FileInfo("\\\\" + textBox1.Text +
> "\\c\\Program Files\\Microsoft SQL
> Server\\MSSQL\\Data\\MYDATABASE_Data.Mdf");
> FileInfo SourceFile2=new FileInfo("\\\\" + textBox1.Text +
> "\\c\\Program Files\\Microsoft SQL
> Server\\MSSQL\\Data\\MYDATABASE_Log.Ldf");
> SourceFile1.CopyTo("D:\\",true);
> SourceFile2.CopyTo("D:\\",true);
> ...and when i start my form, there is this Error Message
> Could not find file"\\ADEMTEKEREK\c\Program Files\Microsoft SQL
> Server\MSSQL\Data\MYDATABASE_Data.Mdf"
> WHAT CAN I DO...'?
> thnks for now....
Do you have a share named "c" on the machine ADEMTEKEREK that is mapped to
the root of drive c? Does the account this code runs under have access to
network shares?
I'd also recommend that you don't just copy the MDF and LDF files as a
backup - if these are in use by SQL Server you will likely end up with
unusable files. Have SQL Server do a BACKUP and then copy those files.
Dan

Monday, February 13, 2012

£ signs etc not being stored in database

Hi,
I'm having a few problems with my forms saving things like £ signs.
I'm trying to store all my data in plain text with-in a MS SQL 2000 database, but for some reason certain characters are being automatically removed. I don't really want to use the HTML code for these characters so was wondering if anyone know how I could stop these characters automatically being removed.
Many thanks in advance.
Below is the code I'm using to insert the text to the database:
----
Dim MyConnection9 As New SQLConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim MySQL9 as string
MySQL9 = "INSERT INTO NEWS_ARTICLES " & _
"(NewsTitle, NewsText, NewsDate, NewsShow) " & _
"VALUEs (@.title, @.text, @.date, @.show)"
Dim Cmd9 as New SqlCommand(MySQL9, MyConnection9)

Dim strtitle, strtext, strimage, strdate, strshow
strtitle = txttitle.Text
strtext = txtText.Text
strdate = DateTime.Now
strshow = ddlShow.SelectedItem.Value

cmd9.Parameters.Add(New SqlParameter("@.title", strtitle))
cmd9.Parameters.Add(New SqlParameter("@.text", strtext))
cmd9.Parameters.Add(New SqlParameter("@.date", strdate))
cmd9.Parameters.Add(New SqlParameter("@.show", strshow))

MyConnection9.Open()
cmd9.ExecuteNonQuery
MyConnection9.Close()
----
Regards,
Rich

What data type are you using? See this article from BOL on Unicode characters.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/acdata/ac_8_con_03_6voh.asp
When I run this, it works.
declare @.test nvarchar(50)

set @.test = '£'

select @.test

Nick

|||

Hi Nick,

Thanks for your reply. I'm using nvarchar and also ntext.

Do you think it's my code that's wrong? Or something on the SQL setup?

If I edit it via SQL enterprise manager, it works ok.

Regards,

Rich

|||I would recommend you set a break point in your code and run it in debug mode. This sounds like its an issue of your web code not holding the value correctly. How are you getting the value including the£into your string variable? Does it come from a textbox? If so, how does it get added to your textbox (key pattern, copy and paste, etc)?
Nick|||

Hi Nick,
I'm getting the £ signs from within a textbox, either by pasting one in there or by using the £ on the keyboard.
I've tried changing the cost and instead of using the textbox text, I replaced it with a £ which worked. So I think it's somewhere in the below code I'm using, but I just can't seem to figure it out :(
Dim strtitle, strtext, strimage, strdate, strshow
strtitle = txttitle.Text
strtext = txtText.Text
strdate = DateTime.Now
strshow = ddlShow.SelectedItem.Value
'strimage = ddlImage.SelectedItem.Value

cmd9.Parameters.Add(New SqlParameter("@.title", strtitle))
cmd9.Parameters.Add(New SqlParameter("@.text", strtext))
cmd9.Parameters.Add(New SqlParameter("@.date", strdate))
cmd9.Parameters.Add(New SqlParameter("@.show", strshow))
Thanks again for your help so far.
Regards,
Rich

|||

Hi Nick,

When you say insert a break point? What does this mean? It's unfortunately not a term I'm familiar with :(

Regards,

Rich

|||

I wonder if the issue is the parm construction. I think it might be seeing the £ sign, and the datatype is being converted to money (That is the English symbol for money right?) Maybe try:
dim parm as new sqlParameter("@.title", sqldbType.varchar, 50)
parm.Value = strTitle
cmd9.Parameters.add(parm)
Does cmd9.Parameters.Add(New SqlParameter("@.title", "£")) work?

Nick
Edit: forgot the parm.add

|||

Hi Nick,

Thanks again for your reply.

I tried your suggested code, but unfortunately it didn't make any difference. Although, cmd9.Parameters.Add(New SqlParameter("@.title", "£")) did work.
I also tried:
dim parm as new sqlParameter("@.title", sqldbType.varchar, 50)
parm.Value = txtTitle.Text
cmd9.Parameters.add(parm)
My textbox code is:
<asp:TextBox ID="txtTitle" runat="server" Width="350" />
Does that look ok?

Cheers,

Rich

|||

Try outputting the value

response.write (me.txtTitle.text) : response.end

If it doesnt have the value, the encoding isnt happening correctly. Try:

response.write (request.form("txtTitle")) : response.end
See if that helps any. Im kind of lost on this one as I tried it myself and everything seemed okay.
Nick

|||

Hi Nick,
Thanks again for your reply. Same thing happens when I do this also :(
$ works, but not £, very strange...
Thanks again for all your help.
Cheers,
Rich

|||

Could the problem be with the below bit of code which is also used on the page?
<%@. Page Language="VB" ContentType="text/html" validateRequest=false ResponseEncoding="iso-8859-1" debug="True" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.SQLClient" %>
<%@. Import Namespace="System.Web.Mail" %>
<%@. Import Namespace="System.DateTime" %>
Cheers,
Rich

Saturday, February 11, 2012

#ERROR on SUM if Field value is a string

Hi,

I have some columns that can be either a Number or Text.

and I have to sum all the value if that column is a Number, therefore in my Table footer i have:

=IIF(IsNumeric(Fields!Col1.Value),Sum(Fields!Col1.Value),"")

However this will give me #ERROR if the columns is Text. It works for Number.

Any help is appreciated, thanks

Jon

Try =Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,""))

|||

Thanks for your reply.

unforunately i tried you suggestion but it didn't help, it still gives me #error

any other idea i can try?

thanks

|||

How about:

=Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,Nothing))

or

=Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,0))

|||

Thanks!

=Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,Nothing))

works well for most of them, but Not on columns which are TRUE/FALSE?

|||

Do you mean columns that are declared as a of Bit data type? If so, they are probably passing the IsNumeric test.

|||

Try:

=IIF(IsNumeric(Fields!Col1.Value),Sum(val(Fields!Col1.Value)),0)

Val() function returns the number part of the string.

Somiya.

#ERROR on SUM if Field value is a string

Hi,

I have some columns that can be either a Number or Text.

and I have to sum all the value if that column is a Number, therefore in my Table footer i have:

=IIF(IsNumeric(Fields!Col1.Value),Sum(Fields!Col1.Value),"")

However this will give me #ERROR if the columns is Text. It works for Number.

Any help is appreciated, thanks

Jon

Try =Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,""))

|||

Thanks for your reply.

unforunately i tried you suggestion but it didn't help, it still gives me #error

any other idea i can try?

thanks

|||

How about:

=Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,Nothing))

or

=Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,0))

|||

Thanks!

=Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,Nothing))

works well for most of them, but Not on columns which are TRUE/FALSE?

|||

Do you mean columns that are declared as a of Bit data type? If so, they are probably passing the IsNumeric test.

|||

Try:

=IIF(IsNumeric(Fields!Col1.Value),Sum(val(Fields!Col1.Value)),0)

Val() function returns the number part of the string.

Somiya.

#ERROR on SUM if Field value is a string

Hi,

I have some columns that can be either a Number or Text.

and I have to sum all the value if that column is a Number, therefore in my Table footer i have:

=IIF(IsNumeric(Fields!Col1.Value),Sum(Fields!Col1.Value),"")

However this will give me #ERROR if the columns is Text. It works for Number.

Any help is appreciated, thanks

Jon

Try =Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,""))

|||

Thanks for your reply.

unforunately i tried you suggestion but it didn't help, it still gives me #error

any other idea i can try?

thanks

|||

How about:

=Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,Nothing))

or

=Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,0))

|||

Thanks!

=Sum(IIF(IsNumeric(Fields!Col1.Value),Fields!Col1.Value,Nothing))

works well for most of them, but Not on columns which are TRUE/FALSE?

|||

Do you mean columns that are declared as a of Bit data type? If so, they are probably passing the IsNumeric test.

|||

Try:

=IIF(IsNumeric(Fields!Col1.Value),Sum(val(Fields!Col1.Value)),0)

Val() function returns the number part of the string.

Somiya.