hey frnds, I m creating the database at page load,I m able to do dat.I just want to do check that if the table is already existing,then do not create the table.below code create table-
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlCommand cmd;
string Query;
SqlConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
OpenSQLConnection();
Query = "USE sonia";
cmd=new SqlCommand (Query ,conn) ;
cmd.ExecuteNonQuery ();
Query = "CREATE TABLE EmpInfo(CompCode VARCHAR(100),CompName VARCHAR(100),Address VARCHAR(100),ESINo VARCHAR(100),RegNo VARCHAR(100),TDS VARCHAR(100),Pan1 VARCHAR(100),Pan2 VARCHAR(100),RCN VARCHAR(100),ECN VARCHAR(100),PFRegNo VARCHAR(100),PFGrpCode VARCHAR(100),TAN VARCHAR(100),Sonof VARCHAR(100),FiscalID VARCHAR(100),Phone VARCHAR(100),EMail VARCHAR(100),Website VARCHAR(100))";
cmd = new SqlCommand(Query,conn);
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
lblStatus .Text =ex.Message .ToString ();
}
}
private void OpenSQLConnection()
{
try
{
conn = new SqlConnection("Data Source=SONIA-B408A4159\\SQLEXPRESS;Initial catalog=sonia;Integrated Security=true;");
conn.Open();
}
catch (Exception ex)
{
lblStatus.Text = ex.Message.ToString();
}
}
}