473,394 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Store data into Access

Art
Hi,

I have a small table in an Access database, each record has 3 fields. I want to store 3 values into a record. I looked at the view SQL in Access and saw the following:

INSERT INTO Loaded_Tables ( TableName, Date_Added, [Rows] )
SELECT "abc" AS Expr1, Now() AS Expr2, 100 AS Expr3;

So I guess I can just use this SQL in a OleDbCommand.

Is there a better way to do this? I just found out about DataRows by reading some answers in this discussion area -- is that a good way to do it? If so, I don't know how one stores a DataRow in an Access Table.

I'd appreciate any help.

Thanks,

Art
Nov 20 '05 #1
3 1243
Art,

Are you using a dataset/table, because you are talking about Datarows.

This method you show is probably just to store values in a database by
instance using the command.executenonQuery

When you use a dataadapter and a dataset, you can as well use the
commandbuilder for such insert, delete and update commands, so tell us how
you do retrieve your data.

Cor

I have a small table in an Access database, each record has 3 fields. I want to store 3 values into a record. I looked at the view SQL in Access
and saw the following:
INSERT INTO Loaded_Tables ( TableName, Date_Added, [Rows] )
SELECT "abc" AS Expr1, Now() AS Expr2, 100 AS Expr3;

So I guess I can just use this SQL in a OleDbCommand.

Is there a better way to do this? I just found out about DataRows by reading some answers in this discussion area -- is that a good way to do it?
If so, I don't know how one stores a DataRow in an Access Table.
I'd appreciate any help.

Thanks,

Art

Nov 20 '05 #2
Hi Art,

Untested written in a notepad while copying from a everywhere.

I hope this helps?
And when it is not clear feel free to reply

Cor

\\\
Private cmd as OleDb.OledbCommand
Dim conn As New Data.OleDb.OleDbConnection
=("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\something")
Private Sub AddToLog
conn.Open
cmd.CommandText = "INSERT INTO Logfile (Field1, Field2, Field3)" & _
" VALUES (@Field1, @Field2, @Field3')"
Dim p1 As OleDb.OleDbParameter = cmd.Parameters.Add("@Field1",
OleDb.OleDbType.VarWchar)
Dim p2 As OleDb.OleDbParameter = cmd.Parameters.Add("@Field1",
OleDb.OleDbType.VarWchar)
Dim p3 As OleDb.OleDbParameter = cmd.Parameters.Add("@Field1",
OleDb.OleDbType.VarWchar)
p1.Value = myfield1
p2.Value = myfield2
p3.Value = myfield3
doCmd(cmd)
conn.Close()
End Sub
Private Sub doCmd(ByVal cmd As Data.OleDb.OleDbCommand)
Try
cmd.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message, "OleDbException")
Exit Sub
Catch ex As Exception
MessageBox.Show(ex.Message, "GeneralException")
Exit Sub
End Try
End Sub
///
Nov 20 '05 #3
I forgot to write, the logfile should have in this way an autoincrement
field as primary key.

Cor
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: clwoods | last post by:
I would like to ask is thier a better way to store data other than access tables, I would still like to keep access as the front end. My main quest I suppose is for more speed and maybe security....
4
by: Bayou BoB | last post by:
Hello; Simple question for most I'm sure. I'm curious how many records MS Access will store in a single database? What happens when you reach that number of records? Do you just lose the ability...
2
by: Peter Rilling | last post by:
How does Windows store passwords that it uses? For instance, when you install a service, you can provide it the username and password. This information is stored somehow so that at a later date...
5
by: Roy Gourgi | last post by:
Hi, I am used to working in Visual FoxPro and I would like to be able to create a database and store and retrieve information from it. What is the simplest way to do it and what should I be...
5
by: Guadala Harry | last post by:
What are my options for *securely* storing/retrieving the ID and password used by an ASP.NET application for accessing a SQL Server (using SQL Server authentication)? Please note that this ID and...
0
by: Harley | last post by:
I am trying to write a personal app to keep a bank balance and history. The problem I'm haveing is finding a decent way to store the data on a pocketpc under .net compact framewok useing vb.net....
3
by: noridotjabi | last post by:
Say I'm writting a program. In this program for some reason I need to store data somewere were I will be able to access it again. I don't want to store it in a file because then it could be...
10
by: Mike9900 | last post by:
Hello, I would like to store application expiration date in a file and store that file in a secure place, so the application can access the file for all the users on that computer. ...
0
by: sajenia | last post by:
i need to design a solid data store device. the prime use of the data store is to store text messages, with each message being structured as a linked list. the logical concept of the store will be a...
2
by: Ryan | last post by:
I am new to .net 2.0 and was wondering how best to leverage its membership capabilities to handle a situation similar to the following: We have a 4 web applications belonging to 3 departments. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.