By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,241 Members | 1,979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,241 IT Pros & Developers. It's quick & easy.

Adding records to MS ACCESS

P: n/a
Hi Experts,
I am just into dot net and i want simple code for adding records into Access
table (97) using oledb. There are no queries in the databases and there is
only one table:
Friends with the following fields: FriendID (AutoNumber) FirstName, LastName
and DateOfBirth

Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP

Thanks all
Regards
Manish Sawjiani
--
Three Cheers to Technet for the Help!
Nov 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You create a new connection and command and then execute the command:

Public Function InsterRecord() As Integer
Dim conStr as String ="Provider=Microsoft.OLEDB.Jet.4.0;Data
Source=yourLocalDBpath"
Dim sqlStr as String = "SQL INSERT Statement Here"

Dim con As New OLEDB.OLEDBConnection(conStr)
Dim cmd As New OLEDB.OLEDBCommand(sqlStr, con)
Dim retVal as Integer
Try
con.Open()
Catch ex As OLEDB.OLEDBException
retVal =cmd.ExecuteNonQuery
Finally
con.Close()
End Try

Return retVal
End Function

"Manish Sawjiani" <Ma************@discussions.microsoft.com> wrote in
message news:4F**********************************@microsof t.com...
Hi Experts,
I am just into dot net and i want simple code for adding records into
Access
table (97) using oledb. There are no queries in the databases and there is
only one table:
Friends with the following fields: FriendID (AutoNumber) FirstName,
LastName
and DateOfBirth

Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP

Thanks all
Regards
Manish Sawjiani
--
Three Cheers to Technet for the Help!

Nov 22 '05 #2

P: n/a
Thanks Scott M

This code works - BUT NOTHING Happens in the DB!!! Please Help

Regards

"Scott M." wrote:
You create a new connection and command and then execute the command:

Public Function InsterRecord() As Integer
Dim conStr as String ="Provider=Microsoft.OLEDB.Jet.4.0;Data
Source=yourLocalDBpath"
Dim sqlStr as String = "SQL INSERT Statement Here"

Dim con As New OLEDB.OLEDBConnection(conStr)
Dim cmd As New OLEDB.OLEDBCommand(sqlStr, con)
Dim retVal as Integer
Try
con.Open()
Catch ex As OLEDB.OLEDBException
retVal =cmd.ExecuteNonQuery
Finally
con.Close()
End Try

Return retVal
End Function

"Manish Sawjiani" <Ma************@discussions.microsoft.com> wrote in
message news:4F**********************************@microsof t.com...
Hi Experts,
I am just into dot net and i want simple code for adding records into
Access
table (97) using oledb. There are no queries in the databases and there is
only one table:
Friends with the following fields: FriendID (AutoNumber) FirstName,
LastName
and DateOfBirth

Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP

Thanks all
Regards
Manish Sawjiani
--
Three Cheers to Technet for the Help!


Nov 22 '05 #3

P: n/a
On Thu, 3 Feb 2005 20:01:02 -0800, Manish Sawjiani <Ma************@discussions.microsoft.com> wrote:

Hi Experts,
I am just into dot net and i want simple code for adding records into Access
table (97) using oledb. There are no queries in the databases and there is
only one table:
Friends with the following fields: FriendID (AutoNumber) FirstName, LastName
and DateOfBirth

Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP

See if the following helps:

HOW TO: Use Microsoft Visual Basic .NET to Connect to a Microsoft Access Database and to Retrieve
Data
http://support.microsoft.com/default...b;en-us;821765
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 22 '05 #4

P: n/a
You need to give us what you wrote so we can troubleshoot it.

"Manish Sawjiani" <Ma************@discussions.microsoft.com> wrote in
message news:1D**********************************@microsof t.com...
Thanks Scott M

This code works - BUT NOTHING Happens in the DB!!! Please Help

Regards

"Scott M." wrote:
You create a new connection and command and then execute the command:

Public Function InsterRecord() As Integer
Dim conStr as String ="Provider=Microsoft.OLEDB.Jet.4.0;Data
Source=yourLocalDBpath"
Dim sqlStr as String = "SQL INSERT Statement Here"

Dim con As New OLEDB.OLEDBConnection(conStr)
Dim cmd As New OLEDB.OLEDBCommand(sqlStr, con)
Dim retVal as Integer
Try
con.Open()
Catch ex As OLEDB.OLEDBException
retVal =cmd.ExecuteNonQuery
Finally
con.Close()
End Try

Return retVal
End Function

"Manish Sawjiani" <Ma************@discussions.microsoft.com> wrote in
message news:4F**********************************@microsof t.com...
> Hi Experts,
> I am just into dot net and i want simple code for adding records into
> Access
> table (97) using oledb. There are no queries in the databases and there
> is
> only one table:
> Friends with the following fields: FriendID (AutoNumber) FirstName,
> LastName
> and DateOfBirth
>
> Please I have tried everything. WOULD BE HIGHLY OBLIGED for HELP
>
> Thanks all
> Regards
> Manish Sawjiani
> --
> Three Cheers to Technet for the Help!


Nov 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.