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

add column to an existing ms database permanently

1
Hello everyone I need help with adding a column in ms access database and update it with a value.Here is my code, it gives an error that says syntax error in field definition.please correct me.

Expand|Select|Wrap|Line Numbers
  1. string myConn = " ";
  2.  
  3. myConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/EmployeeAttendanceRegister/EmployeeAttendanceRegister.accdb";
  4.  
  5. OleDbConnection myCon = new OleDbConnection(myConn);
  6.  
  7. string myInsert = "ALTER TABLE Attendance ADD COLUMN SignIn" + dateTimePicker1.Value;
  8.  
  9. OleDbCommand myCom = new OleDbCommand(myInsert);
  10. myCom.Connection = myCon;
  11.  
  12. myCon.Open();
  13. try
  14. {
  15.  myCom.ExecuteNonQuery();
  16.  }
  17.  catch (Exception ex)
  18.  {
  19.  MessageBox.Show(ex.Message.ToString());
  20. }
  21. myCon.Close();
  22.             }
Oct 5 '13 #1
1 1528
Rabbit
12,516 Expert Mod 8TB
You didn't give the new column a data type. And I assume your date time picker value is what you want to use as the default value for that column. You need to use the default keyword to do that.
Oct 5 '13 #2

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

Similar topics

2
by: Jonathan | last post by:
Hi, I'm trying to make it possible to add a column/field to an existing database table without transferring the information to a new table (with the column added) altogether. Is there a simple...
2
by: kuhni | last post by:
Hi everybody, I am totally desperate because I cannot solve a really simple problem: I have a specific text-file which I want to import into an existing database. The problem is that the columns...
9
by: Kate | last post by:
I have an existing database in Access, and just want to add one more field. I thought it would be fairly easy, but I can't find the answer!!
0
by: jakeesgirl | last post by:
I have an existing database I created in sql server 2000 express that I connect to through the program I'm creating in c# visual studio express. However, I want to add the actual database to my...
0
by: jakeesgirl | last post by:
I have an existing database I created in sql server 2000 express that I connect to through the program I'm creating in c# visual studio express. However, I want to add the actual database to my...
2
by: anonymoushamster | last post by:
Dropdown A is column from database Dropdown B is column from database Data in A and B must be from same row. If user click an item from A, then B is updated to display its data from...
6
by: julietmachiwa | last post by:
I have an existing database 8i . I just installed Developer 2000 for Windows NT I am failing to connect to the database. How should I configure it? I tried using SQL Net Easy Configuration and...
4
by: aradhanathawait | last post by:
Hi all, Can I change the character encoding of an existing database. I have to store Unicode data in the database. Please help. Regards, Aradhana
3
by: indyanguy01 | last post by:
We already have an application in production with a database (SQL Server 2005) of users. We want to include a section in the application that has Web Parts in them. I understand that out of the...
10
by: hedges98 | last post by:
I'm not sure if the title of the thread is relevant but I think it explains my problem... This is going to be loooooong... Basically, I am working on altering/improving an existing database but...
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:
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...
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,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.