Dim connectionString As String
        Dim cnn As OleDbConnection
        Dim cmd As OleDbCommand
        Dim sql As String

        connectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = d:\sprrg\scm\scm\sprrg.mdb"

        sql = "insert into mr_detail select job_Code,mr_no,item_code,qty,addl_description"

        cnn = New OleDbConnection(connectionString)
        cnn.Open()
        cmd = New OleDbCommand(sql, cnn)

        cmd.ExecuteNonQuery()
        cmd.Dispose()
        cnn.Close()

I am getting eror as No value given for one or more required parameters in the line cmd.ExecureNonQuery().

Kindly advice...

You are mixing two different SQL commands together -- both of which are incomplete.

I imagine the pre-parser sees that you either need to supply parameters or complete the statement so it can determine what to send to the database.

So, are you doing an insert or a select?

Edited 4 Years Ago by thines01: clarity

Your statement

sql = "insert into mr_detail select job_Code,mr_no,item_code,qty,addl_description"

would be complete except you have failed to name the table you are selecting from. For example, if I have two tables containg names, I can do the following

insert into table2 (lname,fname) select last_name,first_name from table1 where last_name like 'Jo%'

This will add to table2 all records from table1 where the last name starts with Jo

check this , may be it helps you

dim myCon as new sqlconnection("your connection string")
dim cmd as new sqlcommand
myCon.open()
cmd.connection=myCon
cmd.commandtext="insert into tablename (field1,field2,field3) values (@field1,@field2,@field3)"
cmd.parameter.add("@field1",______).value = txtvalue1.text 'in place of ___ write datatype of your field in your db.
cmd.parameter.add("@field2",______).value = txtvalue2.text
cmd.parameter.add("@field3",______).value = txtvalue3.text'if you have datatype of your field in your db is int , decimal , bigint, etc then use val(txtvalue.text)
cmd.executenonquery()
myCon.close

Regards

This article has been dead for over six months. Start a new discussion instead.