English 中文(简体)
我怎么能允许用户以2005年数字领域储存的价值进入mas?
原标题:How can I allow users to enter commas in a value that will be stored in an sql server 2005 numeric field?

I have a table field whose Datatype is numeric(10, 1). This field stores the AmountPaid and the user prefers to enter the Amount Value with commas in between like 78,234,673 because that s what they re used to, otherwise they will making a lot of errors.

是否有办法允许 value在价值上,但在储蓄时予以删除,或者有办法在<条码>SQL-SERVER/code>上储存,而无需改动<条码>。 DATATYPE

最佳回答

Double.Parse(TextBox1.Text) is what i was looking for.

问题回答

It s not clear how you re parsing the values from the UI, or what type you re parsing them as, but you may find that NumberStyles.AllowThousands is what you re after. I assume you are parsing the user input as a number and passing that to SQL Server as a parameter value, rather than just including it in the SQL verbatim... if not, that s the first change to make.

I m not sure either what your after but if you want to basically pass into SQL an array of ints have you thought about passing in the string you have (which seems to be in Comma Seperated Values) and then splitting them into the values you need inside SQL. Then placing them in the desired table.

几天前,我不得不做一些类似的事情,但正是要建立一个Oracle数据库,而这个数据库并没有单独发挥作用。 该守则是简便的,你不应把它变成服务器。

CREATE OR REPLACE PACKAGE SPLIT_FNC IS
  -- Create a Type to be used as a temp table
  TYPE strArray IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
  FUNCTION SPLIT_STR(word IN VARCHAR2) RETURN strArray;
END;

CREATE OR REPLACE PACKAGE BODY SPLIT_FNC IS
  FUNCTION SPLIT_STR(word IN VARCHAR2) RETURN strArray IS items strArray;
    temp NUMBER;
    delim CHAR :=  , ;
    start_index NUMBER := 1;
    end_index NUMBER := -1;
  BEGIN
    temp := 1;
    -- If INSTR can not find a match it will return 0
    WHILE end_index != 0 LOOP
      -- Find location of next comma
      end_index := INSTR(word, delim, start_index, 1);
      CASE 
        WHEN
          end_index = 0
        THEN
          -- Catch the last value
          items(temp) :=  SUBSTR(word, start_index);
        ELSE
          -- Get substring of start to next comma
          items(temp) :=  SUBSTR(word, start_index, end_index - start_index);
      END CASE;
      start_index := end_index + 1;
      temp := temp + 1;
    END LOOP;
    RETURN items;
  END SPLIT_STR;  
END SPLIT_FNC;

Hopefully this is helpful - Ankou





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签