473,788 Members | 3,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with data type

44 New Member
Hi

I have to insert the commision value and date into the database. For that I have given the coding as
Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Data
  3. Imports System.Configuration
  4. Imports System.Data.SqlClient
  5. Partial Class commision1
  6. Inherits System.Web.UI.Page
  7. Public strConnection As String
  8.  
  9. Public Conn As SqlConnection
  10. Public Sql As String
  11. Public AdditionalSQL As String
  12.  
  13. Protected Sub btncommission_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btncommission.Click
  14. If Page.IsValid Then
  15. Dim cmdItem As New SqlCommand
  16. Dim commision As String = txtCommission.Text
  17. Dim EffectiveDate As String = txtDate.Text
  18.  
  19. cmdItem.Connection = GetConnection()
  20.  
  21. cmdItem.CommandType = CommandType.StoredProcedure
  22. cmdItem.CommandText = "sp_CommisionAdd"
  23.  
  24. Dim paramcommision As New SqlParameter("@commision", SqlDbType.Decimal)
  25. paramcommision.Value = commision
  26. cmdItem.Parameters.Add(commision)
  27.  
  28. Dim paramEffectiveDate As New SqlParameter("@EffectiveDate", SqlDbType.SmallDateTime)
  29. paramEffectiveDate.Value = EffectiveDate
  30. cmdItem.Parameters.Add(paramEffectiveDate)
  31. cmdItem.ExecuteNonQuery()
  32.  
  33. End If
  34. End Sub
  35. Public Function GetConnection() As SqlConnection
  36. strConnection = ConfigurationManager.AppSettings.Get("ConnectString")
  37. Conn = New SqlConnection(strConnection)
  38. Conn.Open()
  39. Return Conn
  40. End Function
  41. End Class
  42.  
In sql server 2005 I have a table named commision with feilds as

Commision decimal(2,2)
EffectiveDate smalldatetime


but while running I am getting the error as

The SqlParameterCol lection only accepts non-null SqlParameter type objects, not String objects.
Jul 30 '08 #1
4 1489
sweatha
44 New Member
Hi

Then I replaced the lines

Dim commision As String = txtCommission.T ext
Dim EffectiveDate As String = txtDate.Text

as

Dim commision As Decimal = txtCommission.T ext
Dim EffectiveDate As Date = txtDate.Text

but while running the error is

The SqlParameterCol lection only accepts non-null SqlParameter type objects, not Decimal objects.
Jul 30 '08 #2
DrBunchman
979 Recognized Expert Contributor
Hi sweatha,

I think there's a problem on line 25. You define your SQLParameter but then instead of adding that you add the variable commission to your SQLCommand.

Hope this helps,

Dr B
Jul 30 '08 #3
sweatha
44 New Member
Hi

I have changed the line no 25 as

cmdItem.Paramet ers.Add(paramco mm)

But still I got the error as

Error converting data type numeric to decimal.
Jul 31 '08 #4
DrBunchman
979 Recognized Expert Contributor
I'd have thought this one was self explanatory!

It's telling you what the error is - you are trying to pass a variable of type Numeric to one of type Decimal. Check that the data type of your sql parameter, your sql parameter object and the variable you are passing in to it all match.

Dr B
Jul 31 '08 #5

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

Similar topics

0
1726
by: john | last post by:
Hi,All Gurus: It is kind of complicated, please bear with me and let me know if you have any questions. Thanks a lot in advance. John I have a csharp method, using emit to dynamically generate classes & method depends on the meta table in the database,here is my problem 1) One method I generated works when it was called, but another set of method does not work, it generate the following error
0
3941
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
4
4580
by: Alex Sibilev | last post by:
Hello, I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :( I'm writing a "conference board" application (quite similar to ASP.NET forum). I don't use server controls in it (apart from Page). The problem occurs on the page where visitor can post a new messages. Basically, it's a form with couple of
2
4453
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c */ #include <time.h>
2
2962
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import namespace="System.Web.UI.WebControls" %> <%@ import namespace="System.Data" %> <%@ import namespace="System.Data.OleDb" %>
2
8918
by: Ch Pravin | last post by:
Hi All: I am having the following xml which i need to convert to excel using xslt. Please help me out. Afghanistan.xml <?xml version="1.0" encoding="utf-16"?> <Languages BuildVersion="1,5,0815,0 " CountryName="Afghanistan" > <Language locale="English">
5
2383
by: 2beagles | last post by:
I have a template for a three dimensional array that I have been working on using Visual C++ 6.0. Under version 6 this code worked fine. However, last night I downloaded Visual C++ 2005 Express and and trying to get the same code to work. Under Visual C++ 2005 I am seeing linker errors. The problem is in the definition of a couple of friend operators that the linker does not like for some reason. I am assuming I have a mistake in my...
10
2878
by: kkirtac | last post by:
Hi, i have a void pointer and i cast it to an appropriate known type before using. The types which i cast this void* to are, from the Intel's open source computer vision library. Here is my piece of non- working code: CvMat *rowVect = cvCreateMat(1,nfeatures,CV_MAKETYPE(images- //rowVect is a pointer to CvMat type cvReshape( images, rowVect, 0, 1 ); //vectorize the image; readrow is a 1xN matrix(vector)
10
2207
by: oktayarslan | last post by:
Hi all; I have a problem when inserting an element to a vector. All I want is reading some data from a file and putting them into a vector. But the program is crashing after pushing a data which has string value. I really do not understand why push_back() function is trying to remove previously inserted data. Thanks for any help
4
2000
pradeepjain
by: pradeepjain | last post by:
i had posted the same code in javascript area !! this i am posting bcos of different problem. as you can see in ma code there is a dropdown called sort ...its sorts the result by the value he selects . its working fine... say a user selects price as the sort thing . so it lists all mobiles with its price range with mobile in some range together . wht i need to do here is in the say there are 4 groups with diff price range and in each range...
0
9655
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
10363
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...
1
10110
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
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
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
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
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
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.