cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Database connection error in microsoft sqlserver

I hosted an asp.net website built on visual studio 2010 on go daddy but my project did not connect to my database even when I uploaded the correct connections string which include my user name and password
It gives thia error message


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 contacted the godaddy customer support but they dont give a solution they are just burning my call credit pls i need a help, here is my code.

Web.config file



<?xml version="1.0" encoding="UTF-8"?>

<configuration>
<configSections>
</configSections>
<connectionStrings>

<add name="godaddyconnection" connectionString="Data Source=188.121.44.214;Initial Catalog=xxx;Integrated Security=False;User ID=xxxx;Password=hhghhh;" providerName="System.Data.SqlClient" />

</connectionStrings>
<system.web>

<compilation debug="true" targetFramework="4.0" />
</system.web>

</configuration>




The aspx file

%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Welcome skfund </title>
<link rel="stylesheet" href="Content/bootstrap.css" type="text/css" />
</head>
<body>
<form id="form1" runat="server">



<div class="container alert-success">
<header class="icon-bar row img-rounded" style="background-color:#999;">
<div class="col-md-2">
<asp:Image ID="Image1" ImageUrl="~/Image/Upload/Image.JPG" AlternateText="Image" width="120" Height="120" CssClass="img-rounded" runat="server"></asp:Image>


</div>

<div class="col-md-10" style="background-color:#440">
<ul class="nav nav-pills" style="padding:7px 3px 3px 40px; color:White;">
<li role="presentation" class="active"><a href="Index.aspx">Home</a></li>
<li role="presentation"><a href="#">About</a></li>
<li role="presentation"><a href="adminlogin.aspx">Admin</a></li>
<li role="presentation"><a href="Login.aspx">Login</a></li>
<li role="presentation"><a href="Register.aspx">Register</a></li>
<li role="presentation"> <asp:TextBox ID="txtSerch" placeholder="Search"
class="form-control" Width="350" runat="server" TextMode="Search"></asp:TextBox> </li>
<li role="presentation"> <asp:Button ID="BtnSerch" class=" btn btn-primary btn-sm" runat="server" Text="Search"></asp:Button></li>

</ul>
</div>
</header>

<div class="alert-success icon-bar img-rounded" style="background-color:White;">
<center> <h3 style="color:Navy;">...........YOUR FINANCIAL FREEDOM ERA IS HERE</h3>
</center>
<h2>Register page</h2>
<article class="row">
<div class="col-md-4 col-md-push-4 well-lg">
<h3 class="text-info"><span class="glyphicon glyphicon-plus-sign"></span> Register</h3><hr />
<asp:Label ID="lb_info" class="alert-danger" runat="server" Text=""></asp:Label>
<div class="form-group">
<asp:Label ID="LbEmail" runat="server" AssociatedControlID="txtEmail" Text="Email Address"></asp:Label>
<asp:TextBox ID="txtEmail" placeholder="Enter Email" class="form-control" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidatorEmail" runat="server"
ControlToValidate="txtEmail" ErrorMessage="Email is required"
Font-Italic="True" ForeColor="#CC0000"></asp:RequiredFieldValidator>

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmail" ErrorMessage="Enter a Valid Email Id"
ForeColor="#CC0000"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</div>
<div class="form-group">
<asp:Label ID="LbPassword" runat="server" AssociatedControlID="txtPassword" Text="Password"></asp:Label>
<asp:TextBox ID="txtPassword" type="password" class="form-control" placeholder="Enter Password" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtPassword" ErrorMessage="Password is required"
Font-Italic="True" ForeColor="#CC0000"></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<asp:Label ID="LbRetypePswd" runat="server" AssociatedControlID="txtRetypePassword" Text="Retype Password"></asp:Label>
<asp:TextBox ID="txtRetypePassword" type="password" class="form-control" placeholder="Enter Password" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtRetypePassword" ErrorMessage="Retype Password"
Font-Italic="True" ForeColor="#CC0000"></asp:RequiredFieldValidator>

<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtPassword" ControlToValidate="txtRetypePassword"
ErrorMessage="Password must match" ForeColor="#CC0000"></asp:CompareValidator>

</div>
<div class="form-group">
<asp:Label ID="Gender" runat="server" AssociatedControlID="txtGender" Text="Gender"></asp:Label>
<asp:DropDownList ID="txtGender" class="form-control" runat="server">
<asp:ListItem Value="Female"></asp:ListItem>
<asp:ListItem Value="Male"></asp:ListItem>

</asp:DropDownList>

<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtGender" ErrorMessage="Gender is required"
Font-Italic="True" ForeColor="#CC0000"></asp:RequiredFieldValidator>
</div>

<div class="form-group">
<asp:Label ID="Phoneno" runat="server" AssociatedControlID="txtPhoneno" Text="Phone Number"></asp:Label>
<asp:TextBox ID="txtPhoneno" class="form-control" placeholder="Enter Phone Number" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtPhoneno" ErrorMessage="Phone Number is required"
Font-Italic="True" ForeColor="#CC0000"></asp:RequiredFieldValidator>
</div>

<div class="form-group">
<asp:Label ID="State" runat="server" AssociatedControlID="txtState" Text="State"></asp:Label>
<asp:TextBox ID="txtState" class="form-control" placeholder="Enter State" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="txtState" ErrorMessage="State is required"
Font-Italic="True" ForeColor="#CC0000"></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<asp:Label ID="Paymentname" runat="server" AssociatedControlID="txtPaymentname" Text="Payment Name"></asp:Label>
<asp:TextBox ID="txtPaymentname" class="form-control" placeholder="Enter Payment Name" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txtPaymentname" ErrorMessage="Payment Name is required"
Font-Italic="True" ForeColor="#CC0000"></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<asp:Label ID="Paymentmethod" runat="server" AssociatedControlID="txtMethod" Text="Method"></asp:Label>
<asp:DropDownList ID="txtMethod" class="form-control" runat="server">
<asp:ListItem Value="MTN"></asp:ListItem>
<asp:ListItem Value="Airtel"></asp:ListItem>
<asp:ListItem Value="Vodafone"></asp:ListItem>
<asp:ListItem Value="Glo"></asp:ListItem>
<asp:ListItem Value="MTN"></asp:ListItem>
<asp:ListItem Value="Tigo Cash"></asp:ListItem>

</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
ControlToValidate="txtMethod" ErrorMessage="Method is required"
Font-Italic="True" ForeColor="#CC0000"></asp:RequiredFieldValidator>

</div>
<div class="form-group">
<asp:Label ID="paymentnumber" runat="server" AssociatedControlID="txtPaymentnumber" Text="Payment Number"></asp:Label>
<asp:TextBox ID="txtPaymentnumber" class="form-control" placeholder="Enter Password" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
ControlToValidate="txtPaymentnumber" ErrorMessage="Payment Number is required"
Font-Italic="True" ForeColor="#CC0000"></asp:RequiredFieldValidator>

</div>
<asp:Button ID="btnRegister" runat="server" class="btn btn-primary"
Text="Create Account" onclick="btnRegister_Click" ></asp:Button>
<asp:LinkButton ID="btnForgetPassword" runat="server" Text="Already Have an Account?"
></asp:LinkButton> <br />
</div>


</article>
<footer>
<div>
<center>
<asp:ImageButton ID="ImageButton1" src="Image/Upload/Ab%20Facebook.png"
runat="server" Height="20" Width="20"></asp:ImageButton>
<asp:ImageButton ID="ImageButton2" src="Image/Upload/Ab%20skype.png"
runat="server" Height="20" Width="20"></asp:ImageButton>
<asp:ImageButton ID="ImageButton3" src="Image/Upload/Ab%20Whatsapp.png"
runat="server" Height="20" Width="20"></asp:ImageButton>
<asp:ImageButton ID="ImageButton4" src="Image/Upload/Ab%20Yaho.png" runat="server"
Height="20" Width="20"></asp:ImageButton>
<asp:ImageButton ID="ImageButton5" src="Image/Upload/AbTwiter.png" runat="server"
Height="20" Width="20"></asp:ImageButton>
</center>

</div>
<center>
<h4>&copy S.K FUNDS <%:DateTime.Today.Year %></h4>
</footer>

</form>
&lt;script type="text/jscript" src="Scripts/bootstrap.min.js">&lt;/script&gt;
&lt;script type="text/jscript" src="Scripts/jquery-3.1.1.js">&lt;/script&gt;


</body>
</html>







aspx.cs file




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

namespace test
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnRegister_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["godaddyconnection"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("insert into [Skfund].[Register] values (@Email, @password, @Gendar, @PhoneNumber, @State, @PaymentName, @Method, @PaymentNumber, @DateRegistered)", con);
cmd.Parameters.AddWithValue("Email", txtEmail.Text);
cmd.Parameters.AddWithValue("Password", txtPassword.Text);
cmd.Parameters.AddWithValue("Gendar", txtGender.Text);
cmd.Parameters.AddWithValue("PhoneNumber", txtPhoneno.Text);
cmd.Parameters.AddWithValue("State", txtState.Text);
cmd.Parameters.AddWithValue("PaymentName", txtPaymentname.Text);
cmd.Parameters.AddWithValue("Method", txtMethod.Text);
cmd.Parameters.AddWithValue("PaymentNumber", txtPaymentnumber.Text);
cmd.Parameters.AddWithValue("DateRegistered", DateTime.Today.Date.ToString());


SqlCommand cd = new SqlCommand("select * from Register where Email=@Email", con);
cd.Parameters.AddWithValue("@Email", txtEmail.Text);

SqlDataAdapter sda = new SqlDataAdapter(cd);
DataTable dt = new DataTable();

sda.Fill(dt);

int i = cmd.ExecuteNonQuery();


if (dt.Rows.Count > 0)
{
lb_info.Text = "Email already been used";
}
else
{
cmd.ExecuteNonQuery();
con.Close();
lb_info.Text = "Record submitted successfully";

txtRetypePassword.Text = "";
txtPassword.Text = "";
txtEmail.Text = "";
}

}
}
}
1 REPLY 1
Helper V

@Josephayoyinka.

 

Are you able to insert records in your local environment without any errors?...

My knowledge on .NET is limited, anyway please check the below link to have an idea...

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/index

 

Hope this helps

 

Regards,

 

Praveen Thomas

GoDaddy 24/7 Support www.x.co/247support
----->NEXIA