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
C# Copy
protected void Page_Load (object sender, EventArgs e )
{
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0 ).ToString();Code Copy
string strcon = "Data Source=";
strcon += clientIPAddress+";" + "Initial Catalog=POS;Trusted_connection=true";Java Copy
SqlConnection con = new SqlConnection (strcon);
SqlCommand cmd = new SqlCommand ("select * from AllTransactions where BranchKey=" + Convert.ToInt32(Session["BranchKey" ]) + "" , con);Java Copy
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 MalhotraRank #2,120 · 672 reputationPosted Jun 10, 2010, 8:15 AM EDT
The code
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.