Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Visual Studio Tools for Office
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 29th, 2007, 12:08 PM
Registered User
 
Join Date: Dec 2007
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.






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 08:35 AM
Default Value for DATETIME column happygv MySQL 5 August 7th, 2009 04:14 PM
getting default value of a column elygp Need help with your homework? 1 June 18th, 2008 02:41 PM
Error when changing the default page in Tomcat dogmatix Apache Tomcat 1 April 7th, 2005 03:59 PM
Changing default path for Visual Studio .Net help jlecain VS.NET 2002/2003 1 December 23rd, 2003 05:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.