CONVERT function use

I'll go right to the point:

I have a textbox in wich the user can seize a "money" value.
But when i'm doing the INSERT command, it fails and says I cannot implicitely convert nvarchar data (mytextbox.text) to money data.
I don't know how to handle this...

objCmd = New SqlCommand("INSERT INTO tbl_appel_service_pieces " & _
"(fld_nom_piece, fld_quantite, fld_prix, fld_description, fld_num_appel) " & _
"VALUES (@fld_nom_piece, @fld_quantite, @fld_prix, @fld_description, @fld_num_appel)", objConn)
objCmd.Parameters.Add("@fld_nom_piece", champsNomPiece.Text)
objCmd.Parameters.Add("@fld_quantite", champsQuantite.Text)
objCmd.Parameters.Add("@fld_prix", champsPrix.Text)
objCmd.Parameters.Add("@fld_description", champsDescription.Text)
objCmd.Parameters.Add("@fld_num_appel", champsNumAppel.Text)

objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()

afficherPieces()

How and where to do the conversion ? On the VALUES variable ?
0
Okiyah
7/13/2004 8:52:42 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

3 Replies
387 Views

Similar Articles

[PageSpeed] 28

objCmd.Parameters.Add("@fld_nom_piece", SqlDbType.Money)

objCmd.Parameters("@fld_nom_piece").Value = System.Convert.ToDecimal(champsNomPiece.Text)

Kay Lee
MySpace.com - http://www.myspace.com/kragie
Infrastructure Group
MySpace.com

- Code to live, but Live to code.
0
KraGiE
7/13/2004 10:36:43 PM
Thanks ! It worked well.
0
Okiyah
7/14/2004 7:05:11 PM
I have a similar problem in that I have a text box which holds a numeric value and when I try to insert the value into the numeric field in the SQL database I get the same error message. 

I have tried the suggestion above but then I get another error message saying incorrect input.
Any idea's ??
Thanks
0
twissg
7/23/2004 8:41:30 AM
Reply:

Similar Artilces:

Converting a gridView using an Sql Datasource to a gridview who is not using an SQL DataSource
How can i rewrite this page so that i doesnt make use of an SqlDataSource?  <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginHistory.ascx.cs" Inherits="Private_UserControls_WebUserControl" %> <html> <head> <%--<link rel="stylesheet" href="BaldwinPortal.css" mce_href="BaldwinPortal.css" type="text/css" />--%> <title>Login History</title> </head> <body style="margin:0 0 0 0;padding:0 0 0 0"> ...

Not able to use sql Convert function in gridview
 Hi!Im trying to get europe time in one of my gridviews (instead of am/pm format), and tryed using following select-string:SelectCommand="SELECT Convert(DateTime, vagt.start, 13), vagt.***, medarbejder.fornavn + ' ' + medarbejder.efternavn AS Expr1, medarbejder.medarbejder_id, vagt.vagt_id FROM vagt INNER JOIN medarbejder ON vagt.medarbejder_id = medarbejder.medarbejder_id WHERE vagt.dags_id = @intDagsid" The thing to note ofc, is the Convert() part. Now, when i use that method on the "vagt.start" column, it gives me an error stating it cant fint a field...

SQL function using dynamic sql.
 Hi all I am trying to pass a column name as a variable in a function but it will not let me.  I am sure it is something stupid. I know that you cannot pass a column in a normal select statement as a variable. You have to execute it dynamically, however you cannot use the exec in a function. Please see code belowALTER FUNCTION dbo.GetData(@ColumnName varchar(50))RETURNS Decimal(18,4)ASBEGINDECLARE @Value Decimal(18,4)SET @Value = (SELECT + @ColumnName + FROM Policy   WHERE Grade = 'Revised') -- Tried this way, does not work need to use ExecSET @Value = Exec(&...

Using CONVERT function to convert NUMERIC to VARCHAR
I am creating a trigger on a table where 2 columns are defined as numeric. This trigger captures the data and inserts it into another table where I want to combine the numeric data with a statement. I've tried using the CONVERT function, but it is giving me a mis-matched token error. I've looked through the documentation online, but it is not really helping me or I'm not understanding correctly. I've pasted a snippet of what I'm trying to do without using the CONVERT function. **user_level and region_id are the numeric values** select @whatchanged = case ...

Why Visual Studio 2005 ask me to convert a solution already got converted Somebody did the conversion of a solution from .net 1.1 to .net 2.0 by using the automatic conversion wizard of Visual Stu
Why Visual Studio 2005 ask me to convert a solution already got converted Somebody did the conversion of a solution from .net 1.1 to .net 2.0 by using the automatic conversion wizard of Visual Studio 2005. Then, he changed to another company. Now, I take over his job. Unfortunately, when I attempted to open that solution, Visual Studio 2005 prompted me the conversion wizard again to forced me to perform a conversion on the solution. Does someone know why?--Harish Patel www.MicrosoftSQLandASP.netpatelharish@gmail.com Hi, How many projects are in the solution, does it have UNLOADE...

Why do Sending SMTP Authenticated E-mail succeed using SmtpMail.Send() function but fail using SmtpClient.send() function ? Bugs in System.Net.Mail.SmtpClient when send a Authenticated E-mail?
I click btnOK button, the email can send OK, but click btnFail button,  the following error is displayed! why ? you can test the section code. The SMTP, username, password are valid!  Many thanks! "Syntax error, command unrecognized. The server response was: authentication failed,decode user password error" I have tested some other SMTP, somes is OK. I think there are some bugs with System.Net.Mail.SmtpClient when send a Authenticated E-mail with some SMTP!   //------------------------------------------.ASPX Code----------------------------------------...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Why use parts of Ado.net when you can use SQL
Just on this line of thought. Why use objects such as DataTable,DataRow,DataColumn when you can use SQL to select and insert data more effectively. I have been creating applications that use sql queries and stored procedures. The other way to do it would be to use ADO.nets objects that help you like DataTable,DataRow, DataColumn. I hardly ever use them at all so are they really worth going into in depth. I prefer SQL to do all my data manipulation.MCAD.Net vb.net Perhaps you should explain how you use sql queries and stored procedures and how you think they're more effective. I f...

How to change the SQL used for the GridView, when using a control parameter in the datasource
I'm using a GridVeiw with and Access database. I want to allow users to select a date and then update the GridView to show only data entered after that date. So my question is, how do I modify the SQL used by the datagrid? I'm using a control parameter as part of my AccessDataSource and I think that is what I'm having trouble figuring out how to include. Here is my datasource, with the control parameter in the the GridView. The GridView works fine with these initial settings settings. <asp:AccessDataSource ID="AccessDataSourceForwView" runat="server" ConflictDetection="Compa...

Using a date function to declare a variable used in a SQL query
Hi all can you help me, I know that I am doing some thing wrong. What I need to do is set a variable to the current date so I can use it in a SQL query to an access database. This is what I have so far <script runat="server""> Sub Page_Load dim --all the variables for my sql connections-- dim ff1 As Date then my sql connection and queries sql="SELECT FullRate, " & ff1 &" FROM table1 WHERE hotelnumber = " & hotel This works is I set ff1 as a string and specify the string (my column headings are set as dates in my table) dim ff1 As string ff1="30/01/2006" but I need...

Attach SQL DB to SQL Server 2005 using VB.Net
Is there any way to attach a SQL DB to SQL Server 2005 using VB.Net?  If so can you also set security? Can you rephrase your question? Attach SQL DB from which version of SQL server ? Look up books online for sp_attachdb and sp_detachdb.***********************Dinakar NethiLife is short. Enjoy it.*********************** I have a DB that was created in SQL Server 2005.  I have a website that displays data from systems all over the world.  Each system sends it's data to it's own DB.  The customer can then go to a website and see the data at real time.  What ...

used a c#.net to vb.net converter and am now getting a syntax error.
ok I used a cool utility at http://www.kamalpatel.net/ConvertCSharp2VB.aspx to convert some c#.net to vb.net and it spit out a bunch of code which almost works but I am getting a syntax error on this line Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) I tried it that way and also like Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) but either way gave the same error Compiler Error Message: BC30035: Syntax error. Source Error: Line 26: Line ...

how to convert dynamicaly loading images to pdf using HTML to PDF Converter for .NET
how to convert dynamicaly loading images to pdf using HTML to PDF Converter for .NET Now am converting using how to convert dynamicaly loading images to pdf using HTML to PDF Converter for .NET  tool. But the dynamicaly loading images are not showing in the pdf .     Are you using 3rd party tool or you are using iTextSharp free utility? If it is 3rd party tool, it's always suggested to ask the company which built the tool. Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti Hi vishnusekhar, As to convert images/douments ...

SQL Convert function
I am trying to concatenate a string to a currency amount so that I can show both in a drop down list box.  However when I create the SQL to do this using the Query tool I get a message to say that I must use the Convert funtion to convert the currency amount.Anyone know the SQL syntax for this function as I can seem to get it to work. ThanksPaul How does the string which you tried to use as currency look like? In SQL there is a MONEY datatype, which accepcts values like $999:DECLARE @m moneySET @m=$234325SELECT @mWelcome to my SQL/ASPNET forum for Chinese http://51up.org/bbs...

Web resources about - CONVERT function use - asp.net.sql-datasource

Wave function - Wikipedia, the free encyclopedia
... (a ball attached to a spring ) in classical mechanics (A-B) and quantum mechanics (C-H). In quantum mechanics (C-H), the ball has a wave function ...

Four arrested after wedding brawl outside Westella Renaissance function centre
A crowd of people watched on as a violent brawl erupted between two groups outside a wedding reception venue in Sydney's west.

Facebook Updates Search Function; Now Is A Great Time To Run And Check All Your Privacy Settings
Facebook search is… well, kind of a joke. It can tell you which 400 people in your area have similar names to that one person you want to connect ...

Review: HP Spectre 360 A Perfect Mix Of Style, Form, Function
HP Inc. delivers a brushed-aluminum laptop with a new 6th Generation Intel i7 processor, making it one of the best-looking, best-priced and best-performing ...

Add ‘laser beam’ to your iPhone’s long list of functions
Whether for presentations or driving your cat up the wall, laser pointers are as fun as they are useful. Given everything else an iPhone can ...

The Legend of Zelda: Tri Force Heroes has a blacklist function
I've been playing The Legend of Zelda: Tri Force Heroes for a good while now, and although I can't share all my thoughts until next week, I have ...

Why Global Corporations Need To Redesign Their Strategic Planning Function
Corporate strategy teams play an important role in guiding business leaders to make smarter, better and more informed decisions, especially in ...

Sponsored post: Garmin’s fenix 3 Pairs Form and Function with GPS Watch
... timepiece to polish off a professional look, or strap on a rugged stopwatch for our workouts. But when it comes to everyday use, the functional ...

Code Craft – Embedding C++: Timing Virtual Functions
... compiler just like the standard language types. A subtype inherits the characteristics of its parent type and can use, or not, the member functions ...

R2-D2’s Lesser Known Function as a Wine Chiller
Many may not be aware that the multi-talented R2-D2 can also function as an excellent wine chiller, as seen here in a chalk illustration by Travis ...

Resources last updated: 11/21/2015 12:11:04 PM