Unable to connect to a remote database through ASP. NET Hosting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xianxian
    New Member
    • Apr 2015
    • 2

    Unable to connect to a remote database through ASP. NET Hosting

    I have a ASP.NET website and an hosting account on asphostportal.c om.

    I created a SQL Server Database with Direct Access and updated the connection string with the one provided by asphostportal.

    There are no errors, but I see no data being stored in the database on a form submit.

    Code to insert a row is as follows:

    Code:
    public int run_sql(string msg)
    {
        SqlConnection conn = new SqlConnection();
        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter da = new SqlDataAdapter();
        DataSet ds = new DataSet();
        conn.ConnectionString = connString;
        cmd = conn.CreateCommand();
        cmd.CommandText = msg;
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
        return 1;
    
    }

    What could be the issue?
  • athar13
    New Member
    • Apr 2015
    • 3

    #2
    The best way to troubleshoot this is by putting it in a try catch block. In case of any errors, log them. If there are no errors, check you connection string, where is it pointing to?

    Try going around it. Manually add dummy data and try to retrieve it. If it works then try running the query in msg variable directly in query analyser or something to see if the query is actually working.

    If all is well then it should work.

    Comment

    • xianxian
      New Member
      • Apr 2015
      • 2

      #3
      Ok thanks, I'll try it.

      Comment

      • BeastGeek
        New Member
        • Apr 2015
        • 6

        #4
        Please be advised that you need to use correct connection string. Please kindly ask your hosting provider about the correct connection string that you need to use

        Comment

        Working...