[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Shared[/COLOR][/SIZE][SIZE=2] dbCommand [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Data.SqlClient.SqlCommand[/SIZE]
[SIZE=2][SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] DataInsert([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] StrField [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] IntField [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff] If[/COLOR][/SIZE][SIZE=2] dbCommand [/SIZE][SIZE=2][COLOR=#0000ff]Is [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Nothing [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2] dbCommand = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Data.SqlClient.SqlCommand([/SIZE][SIZE=2][COLOR=#800000]"SPName"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] dbCommand.CommandType = CommandType.StoredProcedure[/SIZE]
[SIZE=2] dbCommand.Parameters.AddRange( _[/SIZE]
[SIZE=2][COLOR=#0000ff] New[/COLOR][/SIZE][SIZE=2] System.Data.SqlClient.SqlParameter() { _[/SIZE]
[SIZE=2][COLOR=#0000ff] New[/COLOR][/SIZE][SIZE=2] System.Data.SqlClient.SqlParameter([/SIZE][SIZE=2][COLOR=#800000]"@StrField"[/COLOR][/SIZE][SIZE=2], SqlDbType.NChar, 20, ParameterDirection.Input, [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2], 0, 0, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2], DataRowVersion.Current, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2]), _[/SIZE]
[SIZE=2][COLOR=#0000ff] New[/COLOR][/SIZE][SIZE=2] System.Data.SqlClient.SqlParameter([/SIZE][SIZE=2][COLOR=#800000]"@IntField"[/COLOR][/SIZE][SIZE=2], SqlDbType.Int, 4, ParameterDirection.Input, [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2], 0, 0, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2], DataRowVersion.Current, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2])})[/SIZE]
[SIZE=2][COLOR=#0000ff] End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][COLOR=#0000ff] Dim[/COLOR][/SIZE][SIZE=2] iKey [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] Using[/COLOR][/SIZE][SIZE=2] dbCon [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Data.SqlClient.SqlConnection([/SIZE][SIZE=2][COLOR=#800000]"CONNECTIONSTRING"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2] dbCon.Open()[/SIZE]
[SIZE=2][COLOR=#0000ff] SyncLock[/COLOR][/SIZE][SIZE=2] dbCommand[/SIZE]
[SIZE=2] dbCommand.Connection = dbCon[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][COLOR=#0000ff] With[/COLOR][/SIZE][SIZE=2] dbCommand.Parameters[/SIZE]
[SIZE=2] .Item(0).Value = StrField[/SIZE]
[SIZE=2] .Item(1).Value = IntField[/SIZE]
[SIZE=2][COLOR=#0000ff] End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][COLOR=#0000ff] Try[/COLOR][/SIZE]
[SIZE=2] iKey = [/SIZE][SIZE=2][COLOR=#0000ff]CInt[/COLOR][/SIZE][SIZE=2](dbCommand.ExecuteScalar)[/SIZE]
[SIZE=2][COLOR=#0000ff] Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2] iKey = -1[/SIZE]
[SIZE=2][COLOR=#0000ff] End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]SyncLock[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Using[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[/SIZE]