c# - Wrong data type OleDB Create Table -


i m using following function create access table:

        public static void createtable(string path, string tablename, string[] columnnames)     {         try         {             string connectionstring = creadteconnectionstring(path);             oledbconnection myconnection = new oledbconnection(connectionstring);             myconnection.open();             oledbcommand mycommand = new oledbcommand();             mycommand.connection = myconnection;             string columnam = "[" + columnnames[0] + "] text";              (int = 1; < columnnames.length; i++)             {                     columnam = columnam + ", [" + columnnames[i] + "] text";             }              mycommand.commandtext = "create table [" + tablename + "](" + columnam + ")";             mycommand.executenonquery();             mycommand.connection.close();             console.writeline("access table " + tablename + " created.");         }         catch          {                 console.writeline("access table " + tablename + " exists.");                 return;           }       } 

however if open access table in ms access data type memo, not text. other data types link specified ms dont seem work @ all.

any ideas welcome? thanks!

the access ddl text data type behaves differently depending on context execute statement.

from dao in access, creates bar text field. ado in access, bar memo type.

create table tblfoo (bar text) 

executing statement oledb connection produces same result ado in access.

if want bar actual text field, include field length <= 255.

create table tblfoo (bar text(255)) 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -