Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7578345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:24:36+00:00 2026-05-30T17:24:36+00:00

I’m trying to enter a double value in an SQL update statment, which is

  • 0

I’m trying to enter a double value in an SQL update statment, which is already converted (see code 1), to keep his numbers behind the comma.

(1)

double.TryParse(splitline[8], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out natMB //conversion

(2) Putting my value in an procedure to my SQL statement, i putted natMB into ‘Verbruikgegevens’, index position 2. 0 or 1 indicates if my inputted data is roaming or not. This is a part of an if statement declaring weither it’s roaming or national data.

sqlStatementUpdate(TrafficdataID, 0,     
(Convert.ToDouble(Verbruikgegevens.Rows[intCount].ItemArray[2],   
CultureInfo.InvariantCulture))

(3) SQL statement in Visual studio (C#)

public void sqlStatementUpdate(long TrafficdataID, byte Roaming, double Value)
{
    SqlCommand sqlCmd = new SqlCommand();
    sqlCmd.Connection = connection2;
    sqlCmd.CommandType = CommandType.StoredProcedure;
    sqlCmd.CommandText = "SP_SCTrafficdataDetailUpdate";
    DataAccessHelper.AddParam(sqlCmd, "TDDValue", SqlDbType.Decimal, Convert.ToDecimal(Value));
    DataAccessHelper.AddParam(sqlCmd, "TrafficdataID", SqlDbType.BigInt, TrafficdataID);
    DataAccessHelper.AddParam(sqlCmd, "TDDRoaming", SqlDbType.Bit, Roaming);
    DataAccessHelper.ExecSProcDS(sqlCmd);
}

(4) DataAccesHelper

internal static class DataAccessHelper
{
    public static void AddParam(SqlCommand cmd, string columnName, SqlDbType dbType, object paramvalue)
    {
        if (paramvalue is DateTime)
        {
            if (((DateTime)paramvalue).Date == DateTime.MinValue.Date)
            {
                paramvalue = DBNull.Value;
            }

        }

        if (paramvalue == null)
        {
            paramvalue = DBNull.Value;
        }

        string param = "@" + columnName;
        if (!cmd.Parameters.Contains(param))
        {
            if (dbType == SqlDbType.VarChar || dbType == SqlDbType.NVarChar || dbType == SqlDbType.Char || dbType == SqlDbType.NChar)
                cmd.Parameters.Add(param, dbType, 4000);
            else
                cmd.Parameters.Add(param, dbType);

            cmd.Parameters[param].SourceColumn = columnName;
            cmd.Parameters[param].Value = paramvalue;
        }
    }

    public static DataSet ExecSProcDS(SqlCommand cmd)
    {
        DataSet ds = new DataSet();

        try
        {
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            da.Fill(ds);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
        return ds;
    }

(5) SQL statement

ALTER PROCEDURE [dbo].[SP_SCTrafficdataDetailUpdate] @TDDValue decimal, @TrafficdataID bigint, @TDDRoaming bit
AS
BEGIN
UPDATE    TR_SCTrafficDataDetail
SET              TDDValue = @TDDValue
WHERE     (TDDType = 'Data') AND (TrafficDataID = @TrafficdataID) AND (TDDRoaming = @TDDRoaming)
END

QUESTION: Is it possible that I keep using a double, and also keep my numbers behind the comma when importing the data to my sqltable? Right now it doesn’t seem to work that wel … I defined my Value in my SQLTable as an decimal though

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:24:38+00:00Added an answer on May 30, 2026 at 5:24 pm

    So the question is:

    • I have text input representing numbers, using sometimes a comma and sometimes a period for the decimal separator. How can I convert these reliably to numbers?

    Answer: This has nothing to do with the SQL data types. You need to first write reliable C# code to convert the number to a double or decimal. Either will do – you should use whichever one matches your database.

    The Invariant culture REQUIRES the period as a decimal point, NOT the comma. So you are using the wrong culture if you have commas as decimal separator.

    If you know what format your numbers are in, use the overloaded Parse and specify the format directly.

    If it is from user input, use the user’s culture, OR train the user what format to use.

    Finally, if you have some odd format, you might need to write your own code to regularise the format using regexes.

    Speed issues

    10000 rows is nothing it should take seconds not minutes.

    I notice you are creating a new SqlCommand for each row. Each time you do so it has to go to the SQL server and match up the metadata with the stored proc you are calling.

    Just create it once, and re-use it by setting the values to the values from the new row. Just don’t forget to set the NULL ones to DBNull.Value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.