Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Visual Studio Tools for Office
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Studio Tools for Office Be sure to specify which version you are working with.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio Tools for Office section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 29th, 2007, 12:08 PM
Registered User
 
Join Date: Dec 2007
Location: Elk Grove Village, IL, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem changing Access column default value

I am having a problem changing the default value
for a column with C# code. The simplest way to
do it seems to be to use oleDbDataAdapter1.Fill(dt),
even though I don't actually want to query for
any data in the database? I just want a handle
to the table so I can change one of its columns
default value.

In VS, I setup a oleDbConnection1 using the
Server Explorer/Data Connections.

I just set it up with any old SQL connection
string, I'm not interested in the dataset:

this.oleDbSelectCommand1.CommandText = "SELECT *\r\nFROM table1";
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;

Then, I wrote the following code:
            DataTable dt = new DataTable();
            oleDbDataAdapter1.Fill(dt);
            dt.Columns["color"].DefaultValue = "green";
            oleDbDataAdapter1.Update(dt);
            oleDbConnection1.Close();

This code doesn't work.

I'm looking at the generated code in the designer and
it makes me think that to change the default value for
a column, I should be using

System.Data.OleDb.OleDbParameter

or

oleDbDataAdapter1.TableMappings?

Any help would be appreciated.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing default icon on forms Dunorcaille BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 7 November 4th, 2011 09:35 AM
Default Value for DATETIME column happygv MySQL 5 August 7th, 2009 05:14 PM
getting default value of a column elygp Need help with your homework? 1 June 18th, 2008 03:41 PM
Error when changing the default page in Tomcat dogmatix Apache Tomcat 1 April 7th, 2005 04:59 PM
Changing default path for Visual Studio .Net help jlecain VS.NET 2002/2003 1 December 23rd, 2003 05:07 AM



All times are GMT -4. The time now is 11:28 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.