Click here to Skip to main content
15,903,175 members
Home / Discussions / C#
   

C#

 
GeneralRe: help with a new control Pin
Dave Kreskowiak4-Nov-04 6:23
mveDave Kreskowiak4-Nov-04 6:23 
GeneralBest Practice For .NET Service Pin
SigEpUCI3-Nov-04 15:07
SigEpUCI3-Nov-04 15:07 
GeneralRe: Best Practice For .NET Service Pin
sreejith ss nair3-Nov-04 16:59
sreejith ss nair3-Nov-04 16:59 
GeneralRe: Best Practice For .NET Service Pin
Dave Kreskowiak3-Nov-04 17:17
mveDave Kreskowiak3-Nov-04 17:17 
GeneralRe: Best Practice For .NET Service Pin
Sebastian Schneider4-Nov-04 22:40
Sebastian Schneider4-Nov-04 22:40 
Generalparsing Pin
webhay3-Nov-04 14:17
webhay3-Nov-04 14:17 
GeneralRe: parsing Pin
Dave Kreskowiak3-Nov-04 17:14
mveDave Kreskowiak3-Nov-04 17:14 
GeneralRe: parsing Pin
Charlie Williams3-Nov-04 17:15
Charlie Williams3-Nov-04 17:15 
The Decimal type can't parse an empty string. It's as invalid a decimal as "Frank" is.

Either make sure you're only dealing with valid values in the TextBox before you parse it or catch the FormatException that will be thrown otherwise. You'll get better performance validating the input, though.

By the way, when Dave Kreskowiak asked you about using string concatenation to build your SQL statement a few posts down, this is what he meant.

A much better way is to use parameters in your query. The exact syntax varies from provider to provider, but here's an example:
// Create the command with place-holders for the parameters
OleDbCommand command = new OleDbCommand("Insert INTO test (Name,age,address) Values(?, ?, ?)");
  
// _name, _age, and _address are variables of the appropriate type that are defined
// and validated elsewhere.  I don't add them straight from 
// the TextBoxes because I don't want junk in my database.
command.Parameters.Add(new OleDbParameter("Name", _name));
command.Parameters.Add(new OleDbParameter("Age", _age));
command.Parameters.Add(new OleDbParameter("Address", _address));


Charlie

if(!curlies){ return; }
GeneralRe: parsing Pin
webhay4-Nov-04 1:03
webhay4-Nov-04 1:03 
GeneralRe: parsing Pin
webhay4-Nov-04 1:03
webhay4-Nov-04 1:03 
GeneralRe: parsing Pin
J4amieC4-Nov-04 2:54
J4amieC4-Nov-04 2:54 
GeneralRe: parsing Pin
webhay4-Nov-04 3:17
webhay4-Nov-04 3:17 
Generalfile reading and access database Pin
aquahawk3-Nov-04 11:36
aquahawk3-Nov-04 11:36 
GeneralRe: file reading and access database Pin
HahnTech3-Nov-04 12:09
HahnTech3-Nov-04 12:09 
Generalinput string not in a correct format Pin
webhay3-Nov-04 9:24
webhay3-Nov-04 9:24 
GeneralRe: input string not in a correct format Pin
Jordi Corominas3-Nov-04 10:54
Jordi Corominas3-Nov-04 10:54 
GeneralRe: input string not in a correct format Pin
Dave Kreskowiak3-Nov-04 11:48
mveDave Kreskowiak3-Nov-04 11:48 
GeneralRe: input string not in a correct format Pin
webhay3-Nov-04 12:01
webhay3-Nov-04 12:01 
GeneralRe: input string not in a correct format Pin
Dave Kreskowiak3-Nov-04 17:08
mveDave Kreskowiak3-Nov-04 17:08 
GeneralRe: input string not in a correct format Pin
Jordi Corominas3-Nov-04 21:35
Jordi Corominas3-Nov-04 21:35 
GeneralRe: input string not in a correct format Pin
Dave Kreskowiak4-Nov-04 0:57
mveDave Kreskowiak4-Nov-04 0:57 
GeneralRe: input string not in a correct format Pin
Jordi Corominas4-Nov-04 1:16
Jordi Corominas4-Nov-04 1:16 
Generalregistry key editing/creation Pin
Pyro Joe3-Nov-04 9:11
Pyro Joe3-Nov-04 9:11 
GeneralRe: registry key editing/creation Pin
Alex Korchemniy3-Nov-04 9:18
Alex Korchemniy3-Nov-04 9:18 
GeneralRe: registry key editing/creation Pin
Salil Khedkar3-Nov-04 21:59
Salil Khedkar3-Nov-04 21:59 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.