Inserts a record into the database using the supplied table name and parameters

Namespace:  DbNetLink.Data
Assembly:  DbNetLink.DbNetData (in DbNetLink.DbNetData.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#
public long ExecuteInsert(
	string Sql,
	IDictionary Params
)
Visual Basic (Declaration)
Public Function ExecuteInsert ( _
	Sql As String, _
	Params As IDictionary _
) As Long
Visual C++
public:
long long ExecuteInsert(
	String^ Sql, 
	IDictionary^ Params
)

Parameters

Sql
Type: System..::.String

The insert statement or table name

Params
Type: System.Collections..::.IDictionary

Collection of parameter values

Return Value

Returns the value assigned to the auto-incrementing (where applicable) column or -1. The property [!:DbNetLink.Data.ReturnAutoIncrementValue] must be set to true for the auto-incrementing value to be returned.

Examples

CopyC#
DbNetData Db = new DbNetData( ConfigurationManager.ConnectionStrings["nwind"] );
Db.Open();
ListDictionary Params = new ListDictionary();
// the insert statement automatically using the parameters 
Params["productname"] = ProductName.Value;
Params["categoryid"] = CategoryID.Value;
Params["description"] = ProductName.Description;
Params["discontinued"] = 0;
Db.ReturnAutoIncrementValue = true;
long ProductID = Db.ExecuteInsert("products", Params)
Db.Close();

See Also