Error in database connection
I have created the user form with the help of createnewuser control in Asp.net c#. In the same form I have added one more form to collect the user contact details and I have created the table for that in .mdf file.
In the .cs file I have written below mentioned code to gather the user data, but it works fine in local server and remote server it gives error.
The code :
protectedvoid CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
TextBox UserNameTextBox =
(TextBox)CreateUserWizardStep2.ContentTemplateContainer.Fi ndControl("UserName");
SqlDataSource DataSource =
(SqlDataSource)CreateUserWizardStep2.ContentTemplateContainer.Fi ndControl("InsertExtraInfo");
MembershipUser User = Membership.GetUser(UserNameTextBox.Text);
object UserGUID = User.ProviderUserKey;
DataSource.InsertParameters.Add("UserId", UserGUID.ToString());
DataSource.Insert();
The error what I am getting is:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I have the SQL server IP address, port no. username and password.
Pl. let me know how to fix this error.
Apurva
|