Create Database depending on User Type?

Posted by Shameer.Ali87 under ASP.NET on 2/25/2013 | Points: 10 | Views : 957 | Status : [Member] | Replies : 1
Hello all,

I am designing a website, which will focus on two main users,
one is for administrator & the other is for normal user,
here when admin makes using the site, he should be using database1
where as if a user creates account, he should be using database2,
how can i start this, any help will be thankful

shameer ali shaik


Posted by: Jayakumars on: 3/12/2013 [Member] [MVP] Bronze | Points: 25

try this Code

SqlConnection sqlconAdmin = new SqlConnection(ConfigurationManager.ConnectionStrings["Adminconstr"].ToString());
SqlConnection sqlconUser = new SqlConnection(ConfigurationManager.ConnectionStrings["Userconstr"].ToString());

SqlCommand sqlcmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();

protected void Page_Load(object sender, EventArgs e)

if (Session["UserRole"].ToString() == "Admin")
//Use sqlconAdmin follow them
else if (Session["UserRole"].ToString() == "User")
//Use sqlconUser follow them

if (!Page.IsPostBack)
GridView1.ShowFooter = true;

Your WebConfig Like This 2 connections

<add name="Adminconstr" connectionString="Data source=PcNAme;Initial Catalog=Test;User Id=sa;Pwd=yrpwd;" providerName="System.Data.SqlClient"/>
<add name="Userconstr" connectionString="Data source=PcName;Initial Catalog=Test;User Id=sa;Pwd=yrpwd;" providerName="System.Data.SqlClient"/>

Mark as Answer if its helpful to you

Shameer.Ali87, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response