473,386 Members | 1,706 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,386 software developers and data experts.

how to insert data using arraylist into ms access

How can i insert many data using arraylist in c# and save all the data in database .mdb file ?

How can i add arraylist in name, latitude and longitude so these three things user can input many data on it and save the data in database?

Here is my code:
Expand|Select|Wrap|Line Numbers
  1.  string myConnectionString = "";
  2.  
  3.  
  4.             myConnectionString = "Provider =Microsoft.Jet.OLEDB.4.0; Data Source=E:\\Placemark.mdb";
  5.  
  6.             OleDbConnection myConnection = new OleDbConnection(myConnectionString);
  7.  
  8.             string myInsertQuery = "INSERT INTO placemark " + "(Name, Latitude, Longitude)" + "VALUES(@Name, @Latitude, @Longitude)";
  9.  
  10.  
  11.             OleDbCommand myCommand = new OleDbCommand(myInsertQuery);
  12.  
  13.             myCommand.Connection = myConnection;
  14.  
  15.  
  16.  
  17.     myCommand.CommandText = myInsertQuery;
  18.     myCommand.CommandType = CommandType.Text;
  19.  
  20.     myCommand.Parameters.Add("Name", OleDbType.Char).Value = textBoxPlacemark.Text;
  21.     myCommand.Parameters.Add("Latitude", OleDbType.Char).Value = latitude.Text;
  22.     myCommand.Parameters.Add("Longitude", OleDbType.Char).Value = longitude.Text;
  23.  
  24.  
  25.             myConnection.Open();
  26.             try
  27.             {
  28.  
  29.                 //reader = myCommand.ExecuteReader();
  30.                 myCommand.ExecuteNonQuery();
  31.  
  32.                 MessageBox.Show("record are successful insert");
  33.             }
  34.  
  35.             catch (Exception ex)
  36.             {
  37.  
  38.                 MessageBox.Show(ex.Message.ToString());
  39.             }
  40.  
  41.             myConnection.Close();
  42.  
  43.         }
  44.  
  45.         private void HandleConnection(OleDbConnection myConnection)
  46.         {
  47.             throw new NotImplementedException();
  48.         }
  49.     }
  50.  
Mar 17 '10 #1
2 4748
ThatThatGuy
449 Expert 256MB
write multiple insert statements and pass in as a OLedb Transaction
Mar 17 '10 #2
tlhintoq
3,525 Expert 2GB
Database How-to parts 1 and 2
Database tutorial Part 1
Database tutorial Part 2
Mar 17 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ABinBoston | last post by:
I have a form in a .adp with some values on it that are derived from a lookup I would like to click a Command Button and Add the Data in the textboxes to a Table the form is named...
5
by: dale zhang | last post by:
Hi, I have a C# application with MS access 2003 as DB for password protection. The DB has two tables: one is Logins, the other Visits. When I do the reading as below: SELECT Password FROM...
2
by: David | last post by:
Hi, I have a MySQL database linked to an MS Access front-end. I have an app which works fine with the local copy of the Access DB, but when run with the linked tables for MySQL, it fails. ...
0
by: rajabide4u | last post by:
How to insert data into ms access using javascript
1
by: 1064871 | last post by:
Hi How to insert Data in Microsoft Access database using VB.net regards adil
1
by: reagen | last post by:
dear all, please help me that my script cannot insert data to ms acces. <%@ Page Language="vb" ContentType="text/html"%> <%@ Import NameSpace = "System.Data" %> <%@ Import NameSpace =...
2
by: freddy windey | last post by:
Hi, this my 1st time i join discussion. im just a new programmer. i need help from your expert on this "Insert data using 1 form to 2 different table"- ASP VBscript. example- name: age: DOB:...
1
by: BharathP | last post by:
Hi, I need to transfer data of one of the table in DB2 to Microsoft Access. I tried using DBOP data source using Configuration assistant in DB2 and SQL passthrough in Microsoft Access. I think I'm...
7
by: Ken Jones | last post by:
Can this conversion be done using Microsoft Access? If so how? Could this be done using TRANSFORM and PIVOT SQL statements? The Old Format columns are NO and URL The New Format...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.