Click here to Skip to main content
       

Database

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
QuestionRe: Error Running SPmemberjojoba201115 Oct '12 - 4:52 
Hi
Please help ..
Solutions are not usefull!
but its SP and for example i fill info in that!
NewsRe: Error Running SP [Solved]memberjojoba20115 Nov '12 - 22:37 
Hi,
I my Self solved the problem via this strategy
 
Change the bellow code :
if @ModuleSettings is not NULL
BEGIN
set @param = @param + '[ModuleSettings]=''' + <code>@ModuleSettings</code> + ''',' 
END
 
With :
if @ModuleSettings is not NULL
BEGIN
set @param = @param + '[ModuleSettings]=''' + <code>replace (@ModuleSettings,CHAR(39),char(39)+CHAR(39))</code> + ''',' 
End
 
conclusion :
you should replace :
@ModuleSettings
with :
replace (@ModuleSettings,CHAR(39),char(39)+CHAR(39))

QuestionBug in SQLBulkCopy? Truncates decimal digits after 26 recordsmemberAllan Watkins12 Oct '12 - 14:25 
I believe I've found a very unexpected bug in SQLBulkCopy that took me a while to track down. My test program reads in records from a CSV file with exactly 1 column which is defined as a "numeric(19,5)" for statistical uploads.
 
Condition 1:
If the input file has 25 rows with the only value being the digit zero, followed by a number with a decimal (like '1.23456'), the data is imported perfectly.
Condition 2:
If the input file has 26 rows with the only value being the digit zero (or any non-decimal number), followed by a number with a decimal (like '1.23456'), the data is imported and the last (and any subsequent) rows have the field imported with truncated decimal digits (like '1.00000').
Condition 3:
If the input file has 26 rows and the first row is '0.0', all of the rows are imported perfectly.
 
I've checked the table/field definition for Condition 2 and it's the same as 1 and 3 so there's no manipulation of the field type (as far as I can tell).
 
Is this a bug or am I missing something?
AnswerRe: Bug in SQLBulkCopy? Truncates decimal digits after 26 recordsmemberjschell13 Oct '12 - 11:05 
You say the test file has "1 column".
 
Then you say that each row has "the digit zero, followed by a number with a decimal (like '1.23456'),"
 
Does that mean that it has two columns or that the single number is '01.23456'?
 
Also you should post the following
1. What database version you are using.
2. Example data
3. The relevant code.
4. The database schema you using.
GeneralRe: Bug in SQLBulkCopy? Truncates decimal digits after 26 recordsmemberAllan Watkins13 Oct '12 - 13:02 
Re: the numbers
The test only had a single column although I first noticed the behavior with 100 columns. Each row only has 1 value (zero) until the 27th row which is the decimal number, i.e.
0
0
0
...
0
1.23456
 
Re: other questions
1) The destination was SQL Server 2008 and the SQLBulkCopy came from the .Net 4.5 library. This brings up the question "Is the SQLBulkCopy the culprit or the destination SQL Server instance?"
2) Example data: see above
3) Relevant code
using (SqlConnection connection = new SqlConnection(strConn))
{
    connection.Open();
 
    using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection))
    {
        bulkCopy.DestinationTableName = strSQL_table_name;
        bulkCopy.BatchSize = GetBulkCopySize();
        bulkCopy.BulkCopyTimeout = 2000;
        bulkCopy.NotifyAfter = GetNotifyAfter();
        bulkCopy.SqlRowsCopied += new SqlRowsCopiedEventHandler(OnSqlRowsCopied);
 
        try
        {
            bulkCopy.WriteToServer(results);
        }
        catch (Exception ex)
        {
            string error = ex.Message;
            MessageBox.Show("Error(CSV_To_SQL-a): " + ex.Message);
            return;
        }
 

 
4) single column in a table, name="BigNumeric", data type="numeric(18,5)
GeneralRe: Bug in SQLBulkCopy? Truncates decimal digits after 26 recordsmemberjschell14 Oct '12 - 6:51 
Where is the reader ('results') close?
GeneralRe: Bug in SQLBulkCopy? Truncates decimal digits after 26 recordsmemberMycroft Holmes14 Oct '12 - 15:06 
I presume results is a datatable, have you inspected the content of the table before BC?
Never underestimate the power of human stupidity
RAH

GeneralRe: Bug in SQLBulkCopy? Truncates decimal digits after 26 recordsmemberAllan Watkins14 Oct '12 - 19:36 
No but that was the answer - I was doing an adapter.Fill(datatable) and didn't realize how inept the DataType was being established. I Sniff | :^) assumed Sniff | :^) that the Fill() was doing more work than it was.
 
I used the .Clone() method (found at http://stackoverflow.com/questions/9028029/how-to-change-datatype-of-a-datacolumn-in-a-datatable[^]) which explained how to overcome poorly initiated DataTypes.
 
I've certainly learned a good lesson though - thanks.
GeneralThe "bug" is actually in the Fill() methodmemberAllan Watkins16 Oct '12 - 16:09 
As it turns out, the process still isn't working. The .Clone() didn't work so I tried the .FillSchema() method and it's failing too.
adapter.FillSchema(table, SchemaType.Source);
table.Columns[2].DataType = typeof (Int32);
adapter.Fill(table);
 
The column still gets cast as an Int32 from FillSchema(), then I try to change it to typeof(Decimal) followed by Fill() and the decimal points are still truncated in the resulting DataTable. I even tried to set the DataType to String but that didn't work either.
 
Next I've discovered another practically hidden Microsoft "feature" called TypeGuessRows (and IMEX=1) which supposedly can be modified in the registry or the OleDbConnection string. I haven't gotten it to work yet but at least I know that others have seen this behavior too.
AnswerRe: Bug in SQLBulkCopy? Truncates decimal digits after 26 recordsmemberAadhar Joshi17 Oct '12 - 1:31 
Keep your column in an numeric format OR convert it manually in numeric format so it dont create destruction.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid