.net - C# change mdb filed data type to memo and save it -
i change data type in db "text" "memo". first of all, didnt find "memo" data type in c#. second: got following code execute command in db:
public void sqlcommand(string strsql) { oledbconnection objconnection = null; oledbcommand objcmd = null; string strconnection; strconnection = @"provider=microsoft.jet.oledb.4.0;data source=" + path + "\\tasks.mdb"; objconnection = new oledbconnection(strconnection); objconnection.connectionstring = strconnection; objconnection.open(); objcmd = new oledbcommand(strsql, objconnection); objcmd.executenonquery(); objconnection.close(); updatelistview(); }
how can change 3rd column's data type , save it? can change data type when form_load function:
public void tst() { conn.open(); dataset ds = new dataset(); oledbdataadapter adapter = new oledbdataadapter("select * tasks", conn); adapter.fill(ds); datatable dt = ds.tables[0]; dt.columns[3].datatype = system.type.gettype("system.string"); conn.close(); }
but function, change data type string > , want memo. function no since need run everytime , if change permanently memo have make little if @ begining.
~thanks.
string
in c# equivalent of bothtext
,memo
in supports texts of either length.if understand question correctly think you're misunderstanding you're doing in code. when set
datatype
of column, you're not changing database in way, changing datatype of column indatatable
instance you've created.
if want change structure of database best way manually in access, since i'm not sure if that's supported in ado.net (i suppose might able using alter
statements). otherwise might able using dao
used access/jet way of doing things that, deprecated quite while ago might not work in .net.
Comments
Post a Comment