473,789 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conversion Problem

39 New Member
Hi

I have to insert two textbox values into the database. In sql server 2005, I have the table named Rs with the following fields

Rs decimal(2, 2)
date1 datetime

In front end I have given the coding as

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data
  2. Imports System.Configuration
  3. Imports System.Data.SqlClient
  4. Partial Class commision1
  5.     Inherits System.Web.UI.Page
  6.     Public strConnection As String
  7.  
  8.     Public Conn As SqlConnection
  9.     Public Sql As String
  10.     Public AdditionalSQL As String
  11.  
  12.     Protected Sub btncommission_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btncommission.Click
  13.         If Page.IsValid Then
  14.             Dim cmdItem As New SqlCommand
  15.             Dim Rs As Decimal = txtRs.Text
  16.             Dim Date1 As Date = txtDate1.Text
  17.  
  18.             cmdItem.Connection = GetConnection()
  19.  
  20.             cmdItem.CommandType = CommandType.StoredProcedure
  21.             cmdItem.CommandText = "sp_RsAdd"
  22.  
  23.             Dim paramRs As New SqlParameter("@Rs", SqlDbType.Decimal)
  24.             paramRs.Value = Convert.ToDecimal(Rs)
  25.             cmdItem.Parameters.Add(paramRs)
  26.  
  27.             Dim paramDate1 As New SqlParameter("@Date1", SqlDbType.DateTime)
  28.             paramDate1.Value =Date1.ToString
  29.             cmdItem.Parameters.Add(paramDate1)
  30.             cmdItem.ExecuteNonQuery()
  31.  
  32.         End If
  33.     End Sub
  34.     Public Function GetConnection() As SqlConnection
  35.         strConnection = ConfigurationManager.AppSettings.Get("ConnectString")
  36.         Conn = New SqlConnection(strConnection)
  37.         Conn.Open()
  38.         Return Conn
  39.     End Function
  40. End Class
The stored procedure I have given is

Expand|Select|Wrap|Line Numbers
  1. set ANSI_NULLS ON
  2. set QUOTED_IDENTIFIER ON
  3. go
  4.  
  5.  
  6.  
  7. ALTER Procedure [dbo].[sp_RsAdd]
  8.     @Rs decimal(2,2),
  9.     @Date1 datetime
  10.  
  11. as
  12. Begin
  13.  
  14. INSERT INTO Rs (Rs, Date1)
  15. VALUES (@rs, @Date1)
  16.  
  17. End
But when I run the project, I get the error as

Error converting data type numeric to decimal.
Jul 31 '08 #1
2 1008
myqueries
11 New Member
Hi..

try converting txtRs.Text into decimal format only.May be the value in the text box is numeric.Hope this should be resolved.
Jul 31 '08 #2
Curtis Rutland
3,256 Recognized Expert Specialist
Lines 15 and 16 seem to be your problem. You should explicitly cast the decimal value and the date value using the Convert class.
Jul 31 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3946
by: Vladimir Khvostov | last post by:
Hi, We have some DB2 table on the host that has varchar(3200) columns that are used to store binary data (I know that "varchar(3200) for bit data" should have been used, by modifying host table is not an option at this time). I wrote a Win32 application, which is using DB2 Connect and ODBC to pull the data from the host. I am passing SQL_C_BINARY as a 3rd parameter in SQLBindCol() call, ::SQLBindCol(hStmt, nColNo + 1, SQL_C_BINARY,...
31
6652
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one variable becomes 364 and the other one becomes 365. Does anyone have any insight to what the problem is? Thanks in advance. Bjørn
11
7623
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type Test. I expected the same error from the following line, but it compiles fine. The double is silently truncated to an int and then fed in to the implicit conversion operator. Why does this happen? Is there any way that I can keep the implicit...
3
4461
by: Steve Richter | last post by:
here is a warning I am getting in a C++ .NET compile: c:\SrNet\jury\JuryTest.cpp(55) : warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied while calling the constructor 'MyString::MyString(const wchar_t *)' c:\SrNet\jury\JuryTest.h(21) : see declaration of 'MyString::MyString' The class "StringData" uses a, whatever you call it, operator const
0
1193
by: VB Programmer | last post by:
Simple ASP.NET 1 site. Opened solution in beta 2 of 2.0. Ran thru conversion wizard and it states: "Conversion Complete. There were some errors during conversion." I view the conversion log and for the project there is 1 error... http://localhost/Watersmark/ Conversion Issues - http://localhost/Watersmark/: ERROR: Failed to backup website http://localhost/Watersmark/
4
2908
by: Påhl Melin | last post by:
I have some problems using conversion operators in C++/CLI. In my project I have two ref class:es Signal and SignalMask and I have an conversion function in Signal to convert Signal:s to SignalMask:s. The reason is I have a free function called WaitSignal that accepts av SignalMask where Signals parameters are supposed to implicitly be converted to SignalMask:s. I'm using the SignalMask class because I want to be able to supply a logic...
14
2230
by: Richard G. Riley | last post by:
Would it be wrong to use "implicit casting" instead of the standards "implicit conversion" when talking about implicit conversions between certain data types. The standard mentions "explicit conversion" for a cast operation
6
2810
by: Dhirendra Singh | last post by:
Hi, The following C++ program is not compiling on my system. #include <iostream> using namespace std; class complex { double re, im; public: complex( ) :re(0), im(0) {}
4
2185
by: Coleen | last post by:
Hi All :-) I'm new to this site. I've been trying to convert several .Net 2003 web applications and getting tons of conversion errors. I found this site to help walk me through the conversion process: http://webproject.scottgu.com/VisualBasic/Migration2/Migration2.aspx which is great, however, when I follow the steps in this tutorial exactly, I get 102 conversion errors! Almost all the errors have to do with ambiguous file names, but...
8
5106
by: Nikola | last post by:
Hello, I'm writing a String class for C++ and I'm getting the following error message when using operator: test.cpp: In function ‘int main()’: test.cpp:7: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: string.h:19: note: candidate 1: char Types::String::operator(unsigned int) const
0
9663
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.