hi iam using asp.net with c#
in my application when user login successfully,then in the next page based on the client database i have to display data in a grid view ,
so how to give connection string in asp.net with c#
can you correct my code which helps me
protected void Page_Load(object sender, EventArgs e) { string strHostName = System.Net.Dns.GetHostName(); string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
string strcon = "Data Source="; strcon += clientIPAddress+";" + "Initial Catalog=POS;Trusted_connection=true";
SqlConnection con = new SqlConnection(strcon); SqlCommand cmd = new SqlCommand("select * from AllTransactions where BranchKey=" + Convert.ToInt32(Session["BranchKey"]) + "", con);
SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds, "tt"); GridView1.DataSource = ds.Tables["tt"]; GridView1.DataBind(); }
|
the data is displaying in my system but when client logins it is showing no record, can you correct my code
Kapil Deo MalhotraPosted Jun 10, 2010, 12:15 PM
The code will get the Hostname and the IP address of the server where you are running the Web Application not the Client who is accessing the web application.
So you have number of database based on the Client IP Address. Each user has its Own database?
Can you provide the above information so it will clear my concern?
To get the IP Address of the user who is accessing the Web application, you can use the following
Request.Params["REMOTE_ADDR"]
Let me know if it does not work.