473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Parameter ?_1 has no default value

hi,

This is not something very complicated that i am trying to do. All i am
doing is put data in a datagrid and using a
customised Insert query to insert a row. The data does appear on the
datagrid, but when i insert a new row and use da.update(ds,dt) it gives
this error.

The same thing works fine if i use oledbQueryBuilder instead of my own
InsertCommand, but querybuilder does not usually fulfill the purpose always.
I created a very simplified AccessDatabase with just a table having two
columns.
Please see the code below and i would appreciate ur suggestions.
TIA
irfan

Dim con As New OleDbConnection(ConnString)
da = New OleDbDataAdapter
ds = New DataSet()
Dim cmd As New OleDbCommand("SELECT id,name from table1", con)
da.SelectCommand = cmd
da.Fill(ds, "mytable")

'create an insert command
Dim cmdInsert As New OleDbCommand( _
"INSERT INTO Table1( id, Name) VALUES (?,?)", con)
'create parameter
Dim par1 As New OleDbParameter("id", OleDbType.LongVarWChar)
Dim par2 As New OleDbParameter("Name", OleDbType.VarChar)
'add parameters
cmdInsert.Parameters.Add(par1)
cmdInsert.Parameters.Add(par2)
da.InsertCommand = cmdInsert

Nov 21 '05 #1
1 7489
Hi,

http://msdn.microsoft.com/library/de...andbuilder.asp

Ken
--------------------
"Irfan" <ir***@asc-ltd.co.uk> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
hi,

This is not something very complicated that i am trying to do. All i am
doing is put data in a datagrid and using a
customised Insert query to insert a row. The data does appear on the
datagrid, but when i insert a new row and use da.update(ds,dt) it gives
this error.

The same thing works fine if i use oledbQueryBuilder instead of my own
InsertCommand, but querybuilder does not usually fulfill the purpose always.
I created a very simplified AccessDatabase with just a table having two
columns.
Please see the code below and i would appreciate ur suggestions.
TIA
irfan

Dim con As New OleDbConnection(ConnString)
da = New OleDbDataAdapter
ds = New DataSet()
Dim cmd As New OleDbCommand("SELECT id,name from table1", con)
da.SelectCommand = cmd
da.Fill(ds, "mytable")

'create an insert command
Dim cmdInsert As New OleDbCommand( _
"INSERT INTO Table1( id, Name) VALUES (?,?)", con)
'create parameter
Dim par1 As New OleDbParameter("id", OleDbType.LongVarWChar)
Dim par2 As New OleDbParameter("Name", OleDbType.VarChar)
'add parameters
cmdInsert.Parameters.Add(par1)
cmdInsert.Parameters.Add(par2)
da.InsertCommand = cmdInsert


Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Alex Panayotopoulos | last post by:
Hello all, Maybe I'm being foolish, but I just don't understand why the following code behaves as it does: - = - = - = - class listHolder: def __init__( self, myList= ): self.myList =...
3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
2
by: The Plankmeister | last post by:
Hi... I have a query which I'm accessing through PHP as a stored procedure. However, I need to be able not to pass a couple of parameters in certain situations. When I do this, I get an error: ...
0
by: silesius | last post by:
I've been using VS 2003 to develop a webapplication using C#. Today I exported the application to a remote webserver I begun experiencing problems. It's a simple application that retrieves some...
21
by: Marc DVer | last post by:
I am trying to create a query that can be loaded as a querydef object but not having to assign values to the parameters if I don't want to. Normally when using a parameter query in VBA my code...
10
by: John Austin | last post by:
I am migrating my first vb6 app to vb.net 2003. In the vb6 app a number of subs had optional date parameters: Sub Fred ( ... ,optional FromDate as Date = 0...) I need something like zero in...
4
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx...
1
by: Allan Ebdrup | last post by:
I have an object data source, that takes a parameter sortData, that sorts the data, now I want to have the sorting set to a default value when i first load the ASP.Net 2.0 page. I've tried to set...
6
by: s0suk3 | last post by:
I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: ...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.