0

I am building an appliciation that connects with a database. Now the problem is that i get an error when i try to actually connect to the database. *note, I know its not save, its for testing purposes only.

Also, when i go to the url given in string server = "http://185.13.226.246:2222/CMD_DB/"; directly it will give me an error as in the picture below. But if I go to that URL indirectly (so via navigating) its fine.

It might be a very small problem but I can't find why it does not work.

edit: in the picture below there should be a list of available databases.

enter image description here

   public class DataConnection
{
    private static SqlConnection conn;
    SqlCommand cmd = new SqlCommand();

    public DataConnection() { }

    public static SqlConnection Connection
    {
        get { return conn; }
    }

    public void ReadyConnection()
    {
        string server = "http://185.13.226.246:2222/CMD_DB/";
        string database = "nickbbl114_atop";
        string uid = "bbl114";
        string password = "password010101";
        string port = "2222";
        string connectionString;
        connectionString = "SERVER=" + server + ";" + "DATABASE=" +
        database + ";" + "UID=" + uid + ";" + "PWD=" + password + ";";

        conn = new SqlConnection(connectionString);
        try
        {
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }


    public string Login(string email, string password)
    {
        string naam;

        cmd.CommandText = "Select Voornaam From persoon where email = '" + email + "' and password = '" + password + "'";
        cmd.CommandType = CommandType.Text;
        cmd.Connection = conn;

        ReadyConnection();
        naam = cmd.ExecuteScalar().ToString();

        return naam;
    }
}
1
  • I think you have a fundamental misunderstanding of how database connections work. It's going to take a long answer to field every point you've made, so I implore the community to please be patient with this one.
    – Dai
    Aug 30, 2014 at 11:55

1 Answer 1

0

you can create same database for any type of application either it's in JAVA or Dotnet or PHP.It doesn't matter.

First try to create a service layer in asp.net for Database CRUD operations. 1) EmployeeService - API service. 1.Insert a new record in the table. 2.Delete the record. 3.Update the record.

Sample to create service layer using WCF service - http://www.codeproject.com/Articles/254714/Implement-CRUD-operations-using-RESTful-WCF-Servic

The above layer can be used for both asp.net and PHP.

2)Asp.Net application - Call the above service using Jquery from asp.net application

3)PHP application - Call the above service using jquery from asp.net application

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.