Changing the data type of dataadapter?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • xlar54

    Changing the data type of dataadapter?

    Given this:

    SqlDataAdapter sqlAd = new SqlDataAdapter( sql, sqlCon);

    sqlAd.Fill(ds);

    I find that the data types that are created are not what I want...
    they go by the SQL server data type (which is normally what you would
    want). But I need the data to all be represented as strings. Is it
    possible to change the data types being "Filled"?

    Thanks
  • Alberto Poblacion

    #2
    Re: Changing the data type of dataadapter?

    "xlar54" <scott.hutter@g mail.comwrote in message
    news:a4ac5edd-556f-46bb-a30d-38c90e7f6ec1@d1 g2000hsg.google groups.com...
    SqlDataAdapter sqlAd = new SqlDataAdapter( sql, sqlCon);
    >
    sqlAd.Fill(ds);
    >
    I find that the data types that are created are not what I want...
    they go by the SQL server data type (which is normally what you would
    want). But I need the data to all be represented as strings. Is it
    possible to change the data types being "Filled"?
    One easy way is to modify the sql query so that it converts all fields to
    strings before returning them:

    string sql = "Select Cast(Field1 as varchar(50)) as f1, ...";
    SqlDataAdapter sqlAd = new SqlDataAdapter( sql, sqlCon);
    sqlAd.Fill(ds);

    Comment

    Working...