I am doing a Smart device project The problam is I can not pass parameters to the stored procedure to insert into the database from the PDA emulator for the following sqlDbtypes it gives me the following error

A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.SqlClient.dll

Deicimal
Money
Int
Numeric

these sqlDBtypes work fine when I pass the parameters to the same stored procedure with a windows application( not smart device application). the database gets uupdated correctly.

This is my Code block

public void opendb()
        {
            String connStr = "Data Source=192.168.1.1,1433;Initial Catalog=Resmanagement;User ID=sa;Password=thadiya;";
            myConn1 = new SqlConnection(connStr);

            myConn1.Open();
        }

        public void closedb()
        {
            if (myConn1 != null)
            {
                myConn1.Close();
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            dblPrice = 1000;

            try
            {
                opendb();

                SqlCommand command1 = new SqlCommand("Test2", myConn1);
                command1.CommandType = CommandType.StoredProcedure;

                command1.Parameters.Add("@Price", SqlDbType.Decimal,9, "Price").Value =Convert.ToDecimal(dblPrice);

                command1.ExecuteNonQuery();
                command1.Dispose();

                closedb();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


        }

I am doing a Smart device project The problam is I can not pass parameters to the stored procedure to insert into the database from the PDA emulator for the following sqlDbtypes it gives me the following error

A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.SqlClient.dll

Deicimal
Money
Int
Numeric

these sqlDBtypes work fine when I pass the parameters to the same stored procedure with a windows application( not smart device application). the database gets uupdated correctly.

This is my Code block

public void opendb()
        {
            String connStr = "Data Source=192.168.1.1,1433;Initial Catalog=Resmanagement;User ID=sa;Password=thadiya;";
            myConn1 = new SqlConnection(connStr);

            myConn1.Open();
        }

        public void closedb()
        {
            if (myConn1 != null)
            {
                myConn1.Close();
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            dblPrice = 1000;

            try
            {
                opendb();

                SqlCommand command1 = new SqlCommand("Test2", myConn1);
                command1.CommandType = CommandType.StoredProcedure;

                command1.Parameters.Add("@Price", SqlDbType.Decimal,9, "Price").Value =Convert.ToDecimal(dblPrice);

                command1.ExecuteNonQuery();
                command1.Dispose();

                closedb();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


        } 

end quote.

new corrections

command1.Parameters.Add("@Price", SqlDbTypey.Money,8, "Price").Value=Convert.ToDecimal(dblPrice);

table Defenition(Table name test)---------Price   DataType(money)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.