Click here to Skip to main content
15,898,222 members
Home / Discussions / Database
   

Database

 
GeneralRe: Setting password to a converted database Pin
Rob Graham5-Mar-04 9:18
Rob Graham5-Mar-04 9:18 
GeneralRetrieving Dates from Access Database using ODBC Pin
pavneet3-Mar-04 9:16
pavneet3-Mar-04 9:16 
GeneralRe: Retrieving Dates from Access Database using ODBC Pin
Rob Graham5-Mar-04 9:59
Rob Graham5-Mar-04 9:59 
GeneralRe: Retrieving Dates from Access Database using ODBC Pin
pavneet5-Mar-04 10:03
pavneet5-Mar-04 10:03 
GeneralRe: Retrieving Dates from Access Database using ODBC Pin
Rob Graham7-Mar-04 17:34
Rob Graham7-Mar-04 17:34 
GeneralRe: Retrieving Dates from Access Database using ODBC Pin
pavneet8-Mar-04 8:54
pavneet8-Mar-04 8:54 
GeneralDateTime not updating time Pin
cje3-Mar-04 7:54
cje3-Mar-04 7:54 
GeneralConnecting to MySQL with ODBC Pin
sps-itsec463-Mar-04 2:56
sps-itsec463-Mar-04 2:56 
Hi guys,

I think it's a simple question: I connect to a MySQL database with OdbcDataAdapter and I want to get the schema of the database directly from the database, so I use something like this:
public DataSet GetData()
{
    // Create DataSet
    DataSet ds = new DataSet(datasetName);
    OdbcDataAdapter adapter = new OdbcDataAdapter();
    adapter.SelectCommand = GetSelectAllCmd();  // Generates Query: "SELECT * FROM " + tableName
 
    // Get schema from database
    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
 
    // Rename table
    adapter.TableMappings.Add("Table", tableName);
 
    // Get data
    adapter.Fill(ds);
 
    // Do we have errors?
    if(ds.HasErrors)
        ds.RejectChanges();
    else
        ds.AcceptChanges();
 
    // Free resources
    adapter.Dispose();
 
    return ds;
}
Everything seems working fine, but the schema isn't transfered correctly. The MaxLength property of the DataColumn member has the value of the longest entry in the database. For example if there is a column called 'name' and the database has an entry like 'John' the MaxLength property is 4. But I specified the 'name' column to allow 100 signs while creating the table (... name VARCHAR(100) NOT NULL, ...).
 
Furthermore I'm not able to change the MaxLength property. The following has no effect:
ds.Tables[tableName].Columns["name"].MaxLength = 100;
 
So I'm not able to insert a name to the 'name' column that is longer than 4. I get the error "The value violates the MaxLength limit of this column". Many thanks in advance!!!

Regards, mYkel
Generalconnection to SQL Server from extranet Pin
MyttO3-Mar-04 0:29
MyttO3-Mar-04 0:29 
GeneralRe: connection to SQL Server from extranet Pin
Mike Dimmick3-Mar-04 2:10
Mike Dimmick3-Mar-04 2:10 
GeneralRe: connection to SQL Server from extranet Pin
Mike Dimmick3-Mar-04 2:27
Mike Dimmick3-Mar-04 2:27 
GeneralMany thanks Pin
MyttO4-Mar-04 23:12
MyttO4-Mar-04 23:12 
GeneralConnection from Crystal Report to DataSet Pin
Pablopablo2-Mar-04 16:12
Pablopablo2-Mar-04 16:12 
GeneralRe: Connection from Crystal Report to DataSet Pin
Anonymous9-Mar-04 5:16
Anonymous9-Mar-04 5:16 
GeneralRe: Connection from Crystal Report to DataSet Pin
Pablopablo9-Mar-04 10:00
Pablopablo9-Mar-04 10:00 
GeneralRe: Connection from Crystal Report to DataSet Pin
DustInTheWind10-Mar-04 5:54
DustInTheWind10-Mar-04 5:54 
GeneralRe: Connection from Crystal Report to DataSet Pin
DustInTheWind10-Mar-04 7:29
DustInTheWind10-Mar-04 7:29 
GeneralColumns failing to save data on insert Pin
Mike Osbahr2-Mar-04 12:25
Mike Osbahr2-Mar-04 12:25 
GeneralExport a DataSet to a NEW Excel File Pin
Jeff Monheiser2-Mar-04 3:42
Jeff Monheiser2-Mar-04 3:42 
GeneralRe: Export a DataSet to a NEW Excel File Pin
John Kuhn2-Mar-04 12:43
John Kuhn2-Mar-04 12:43 
GeneralDataSet object : not disposed Pin
mxcad2-Mar-04 3:36
sussmxcad2-Mar-04 3:36 
GeneralRe: DataSet object : not disposed Pin
Mike Dimmick2-Mar-04 6:30
Mike Dimmick2-Mar-04 6:30 
GeneralDataSet object : not disposed Pin
The Bug2-Mar-04 3:36
The Bug2-Mar-04 3:36 
Generalthose xmlbuilder generated objects.. Pin
Anonymous1-Mar-04 23:32
Anonymous1-Mar-04 23:32 
GeneralRe: those xmlbuilder generated objects.. Pin
Mike Dimmick3-Mar-04 2:17
Mike Dimmick3-Mar-04 2:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.