hi
i want create many table with one sqlcommand
------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class Home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Session["userName"]= User.Identity.Name;
string u = Session["userName"].ToString();
if (IsPostBack==false && u!="Admin")
{
SqlConnection connect = new SqlConnection();
connect.ConnectionString = "Data Source=.;Initial Catalog=AspNetSqlProvider;Integrated Security=True";
//string idSelect=string.Format("select UserId from aspnet_Users where UserName = '{0}'",u);
string query1 = string.Format("CREATE TABLE {0}.Profile(ID uniqueidentifier not null,name nvarchar(20) not null,about text null,pic image null) AND CREATE TABLE {0}.Friend (ID uniqueidentifier not null,name nvarchar(20) not null,popular bit null) AND CREATE TABLE {0}.Post(ID_Post int not null,sendItem text null,Img image null) ", u);
SqlCommand cmd = new SqlCommand(query1, connect);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
//AND CREATE TABLE {0}.Friend (ID uniqueidentifier not null,name nvarchar(20) not null,popular bit null) AND CREATE TABLE {0}.Post(ID_Post int not null,sendItem text null,Img image null)
}
else
{
Label1.Text = "ok";
}
}
}and error is
Server Error in '/Personal' Application.
Incorrect syntax near the keyword 'AND'.
Incorrect syntax near the keyword 'AND'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'AND'.
Incorrect syntax near the keyword 'AND'.