Create an access query using SQL as per the example below:-
INSERT INTO tblMyTable ( Field1, Field2, Field3)
VALUES ([pField1], [pField2], [pField3]);
pField1 2 and 3 will now be treated as parameters, the only rules appear to
be that all parameters are mandatory and they must be added in the same order
they are present in the SQL statement.
Hope this helps,
Stuart
1. Text queries in your .NET code: Use ? for each parameter you wish to
supply. Then add in order. This is the easiest.
2. Create a query in Access proper and use the parameter names. This will
work for newer versions of Access and acts much like a stored procedure.
---
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
¤ Hello,
The placeholder is a question mark, not a percent sign. Here is an example:
Dim AccessConn As System.Data.OleDb.OleDbConnection
Dim AccessCommand As System.Data.OleDb.OleDbCommand
Dim strValue As String = "This is a test"
AccessConn = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\db1.mdb")
AccessConn.Open()
AccessCommand = New System.Data.OleDb.OleDbCommand
AccessCommand.Connection = AccessConn
AccessCommand.CommandText = "INSERT INTO MyTable(email) VALUES (?)"
AccessCommand.CommandType = CommandType.Text
AccessCommand.Parameters.Add("email", strValue)
AccessCommand.ExecuteNonQuery()
AccessConn.Close()
Paul ~~~ pcle...@ameritech.net
Microsoft MVP (Visual Basic)
OracleCommand myCommand = new OracleCommand("inset into MyTable
values(:p1)", myConn);
OracleParameter myParam = new OracleParameter();
myParam.Name = "p1";
myParam.OracleType = OracleType.VarChar;
myParam.Value = "some value";
myCommand.Add(myParam);
myCommand.ExecuteNonQuery();
Note that parameter name that is passed to OracleParameter does not have
":".
--
Vladimir Sergeyev
ADO.Net Test Team
Microsoft Corporation
--------------------------------
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
--------------------------------
"Cowboy (Gregory A. Beamer) - MVP" <NoSpamM...@comcast.netNoSpamM> wrote
in message news:84FDEA70-E98D-409A...@microsoft.com...
--
Vladimir Sergeyev
ADO.Net Test Team
Microsoft Corporation
--------------------------------
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
--------------------------------
"Vladimir Sergeyev [MS]" <vla...@online.microsoft.com> wrote in message
news:ODcjSMo$EHA....@TK2MSFTNGP14.phx.gbl...