To Create a table structure on a button click
Hi,
can any one tell me to create a new table in ms access database on the event of a button click, i tried the method of create table but it didn't work.
i need to create a table structure name "subject" with fields
subject code as text [primary key]
subject name as text
in database name quiz ..........
Thanks
Blocked AccountPosted Feb 9, 2009, 3:06 AM
Take the reference of this article.
http://www.csharphelp.com/archives/archive66.html
Anurag AgarwalPosted Feb 25, 2009, 4:40 PM
sql_create = new StringWriter();
sql_create.WriteLine("create table + TSubcode.Text + (srno int not null primary key, quest varchar(255) null,A varchar(255) null,B varchar(255) null,C varchar(255) null,D varchar(255) null)");
sql_create.Flush();
cmd.CommandType = CommandType.Text;
cmd.CommandTimeout = 30;
cmd.CommandText = sql_create.ToString();
cmd.ExecuteNonQuery();
now the problem is with the "TSubcode.Text", if i gve the specific name then code works fine but when i accepts the name frm user
it gives error as
Object reference not set to an instance of an object. at _Default.BCreate_Click(Object sender, EventArgs e)
how to accept table name from user so to create a table in database with tht name.
The above link didn't proved to be of much use Thanx ...........pls help
Vijaya KadiyalaPosted Feb 23, 2009, 8:25 PM
Hi
Are you getting any specific error while creating this?? time being Check out the below link..
http://www.davidhayden.com/blog/dave/archive/2006/01/27/2775.aspx
Thanks -- Vijaya Kadiyala
Anurag AgarwalPosted Feb 23, 2009, 12:35 AM
Blocked AccountPosted Feb 12, 2009, 3:47 AM
Hi,
You can pass the table name like that.
ADOCommand CreateTable = new ADOCommand("Create Table " + TextBox1.Text + "(vno integer,name char(20))", s);
Anurag AgarwalPosted Feb 12, 2009, 3:35 AM