hi sir,my question is that if the user click on button(which is placed in default.aspx,for example) then the database table is created in database(database is placed in sql express 2005)how can do ?.I try this task by another method but the following errors are occurred:
1.'system.Web.UI.Page.Server' is a 'property' but is used like a 'type'.
2.The type or namespace name 'Database' could not be found(are you missing a using directive or an assembly reference?)
3.The name 'DataType' does not exist in the current context.
4.'System.Web.UI.WebControls.Table' does not contain a definition for 'columns' and no extension method 'columns' accepting a first argument of type 'System.Web.UI.WebControls.Table' could be found(are you missing a using directive or an assembly reference.
5.'System.Data.Index' is inaccessible due to its protection level.
6.'System.Data.Index' does not contain a constructor that takes '2' arguments.
7.'System.Data.Index' does not contain a definition for 'IndexKeyType' and no extension method 'IndexKeyType' accepting a first argument of type 'System.Data.Index' could be found(are you missing a using directive or an assembly reference?)
8.The name 'IndexKeyType' does not exist in the current context.
9.'System.Data.Index' does not contain a definition for'IndexedColumns' and no extension method 'IndexedColumns' accepting a first argument of type 'System.Data.Index' could be found(are you missing a using directive or assembly reference?)
10.The type or namespace name 'Indexedcolumn' could not be found(are you missing a using directive or an assembly reference?)
11.'System.Web.UI.WebControls.Table' does not contain a definition for 'Indexes' and no extension method 'Indexes' accepting a first argument of type 'System.Web.UI.Webcontrols.Table' could be found(are you missing a using directive or an assembly reference?)
13.'System.Web.UI.WebControls.Table' does not Contain a definition for 'Create' and no extension method 'Create' accepting a first argument of type 'Systen.Web.UI.WebControls.Table' could be found(are you missing a using directive or an assembly reference?)
The code written in c# behind the button is that:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;
using System.Text;
using System.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["gameConnectionString"].ConnectionString;
SqlConnection connection =
new SqlConnection(connectionString);
Server server =
new Server(new ServerConnection(connection));
Database db = server.Databases["game"];
Table newTable = new Table(db, "TestTable");
Column idColumn = new Column(newTable, "ID");
idColumn.DataType = DataType.Int;
idColumn.Nullable = false;
idColumn.Identity = true;
idColumn.IdentitySeed = 1;
idColumn.IdentityIncrement = 1;
Column titleColumn = new Column(newTable, "Title");
titleColumn.DataType = DataType.VarChar(50);
titleColumn.Nullable = false;
newTable.Columns.Add(idColumn);
newTable.Columns.Add(titleColumn);
Index index = new Index(newTable, "PK_TestTable");
index.IndexKeyType = IndexKeyType.DriPrimaryKey;
index.IndexedColumns.Add(new IndexedColumn(index, "ID"));
newTable.Indexes.Add(index);
newTable.Create();
}
}
sir please solve these errors and also give the solution in detail through which i can easily understand.I am very confused in this task please help me.Thank sir
[edit]code wraped in pre tag[/edit]