Data Browser
- Viewing Site
Sector 23 Code Bank
Logged in as:
Guest
Similar Topics...
Set width of anchor (a) in CSS
Get Icon for Windows File Type Extension - C
Update or Add Custom Field in JIRA using Atlassian C# API
Download a file from the internet in C
C# Forms UI Thread
Download a file from a URL with Selenium in C
Sending a fax using Windows Faxing in C
Image Dissolving in C# - Windows Forms
Testing SQL Code without cache - SQL Server
SQL exception thrown from stored procedure does not raise exception in C
project could not be opened because the microsoft visual c# compiler could not be created QueryService for '{7D960B16-7AF8-11D0-8E5E-00A0C911005A}' failed
Convert a String to Base64 in C
Add Prompt on C# Webpage
C# - Close form during Load Event
LINQ function to concatenate elements into a string
Sql Server Statistics
Installing Fonts in C
Get Executable Path in C
Using new Microsoft Azure (Bing) Translation API via C
Should you use var in C
Binding to a C# ComboBox
string trim in sql server
Best Practices - C# .NET Naming Conventions
C# Member not found
AngularJS function to format a number with min/max decimals
Insert Image to PDA database
Insert SqlMembershipProvider User using SQL
Sql Server Identity Insert
JavaScript: Insert an item into an array
Angular ui-grid inserts spaces between capital letters
Problems creating a foreign key in Sql Server
LINQ - Join problems
Sys.WebForms.PageRequestManagerParserErrorException
Msbuild fails if PublishDir contains spaces
MSDEPLOY : error : BACKUP_FAILED
Returning Multiple Aggregates in Group by in LINQ
JavaScript date parse returns different dates in IE versus Chrome
Fixing Directory.GetFiles to return exact match on extension only
HttpPost / HttpGet not returning simple data to Angular 7
Insert with MS Access; return AutoNumber
C
#
Function
to execute
a
SQL
INSERT
statement and
return
the recentmost Autonumber generated (for the
insert
). Since this is within
a
'
connection
' it
should
be fairly autonomous. TODO: Find out whether it needs to be within
a
transaction
as well.
///
/// Execute
Insert
Command
against the
Database
.
///
///
INSERT
command
to execute
/// last generated AutoNumber
value
(for the
insert
)
public static int ExecuteInsert(string sqlText)
{
// establish
a
connection
to an
access
database
hosted on brinkster
System.Data.OleDb.OleDbConnection
connection
= Utilities.Connection;
int id = 0;
//
Create
the
command
object
to perform the insert/update/delete
command
try
{
System.Data.OleDb.OleDbCommand
command
=
new
System.Data.OleDb.OleDbCommand(sqlText,
connection
);
command.ExecuteNonQuery();
sqlText = "
SELECT
@@
IDENTITY
AS IDVal"; //
get
last autonumber
command
=
new
System.Data.OleDb.OleDbCommand(sqlText,
connection
);
object
o = command.ExecuteScalar();
id = Utilities.FromDB(o);
command
=
null
;
}
catch(Exception e)
{
throw
new
System.Exception(sqlText + ", " + e.ToString());
}
finally
{
// now
close
and destroy the
connection
object
connection.Close();
connection
=
null
;
}
return
id;
} //
insert
Created By: amos
3/20/2006 12:13:00 AM
Comments:
>
Guest
12/23/2007 8:04:14 PM
thank you!!!