Hi
I have to insert the commision value and date into the database. For that I have given the coding as
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.
I have to insert the commision value and date into the database. For that I have given the coding as
Code:
Imports System.Data Imports System.Configuration Imports System.Data.SqlClient Partial Class commision1 Inherits System.Web.UI.Page Public strConnection As String Public Conn As SqlConnection Public Sql As String Public AdditionalSQL As String Protected Sub btncommission_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btncommission.Click If Page.IsValid Then Dim cmdItem As New SqlCommand Dim commision As String = txtCommission.Text Dim EffectiveDate As String = txtDate.Text cmdItem.Connection = GetConnection() cmdItem.CommandType = CommandType.StoredProcedure cmdItem.CommandText = "sp_CommisionAdd" Dim paramcommision As New SqlParameter("@commision", SqlDbType.Decimal) paramcommision.Value = commision cmdItem.Parameters.Add(commision) Dim paramEffectiveDate As New SqlParameter("@EffectiveDate", SqlDbType.SmallDateTime) paramEffectiveDate.Value = EffectiveDate cmdItem.Parameters.Add(paramEffectiveDate) cmdItem.ExecuteNonQuery() End If End Sub Public Function GetConnection() As SqlConnection strConnection = ConfigurationManager.AppSettings.Get("ConnectString") Conn = New SqlConnection(strConnection) Conn.Open() Return Conn End Function End Class
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.
Comment