0

Currently I am connecting to an online mySql database. I would like to switch it to a mySql database on my local hard drive and am having problems with the syntax. Unlike the online one I have no UserID or Password. Any help is appreciated. Thank you.

(mysql_real_connect (conn,"urlock.db.5513143.hostedresource.com","urlock","passxxx","useridxxx",0,NULL,0) !=0);

tried this: (mysql_real_connect(conn,"c:\urlock.db","urlock","","",0,NULL,0) !=0);

didn't work.

4 Answers 4

1

That second parameter needs to be a host which represents a network connection. It cannot be an absolute file reference like you might do with MS Access files. So, you need to install MySQL5.X on your system as a service. If you've done this, verify it by either looking for an open port of 3306 (default) via a 'netstat -an' command or simply look in your services for 'MySQL ....'.

If not, download it here: http://dev.mysql.com/downloads/mysql/

Once you get this you will be able to import the this database locally and be able to access it very similar to the online version. i.e. (mysql_real_connect(conn,"localhost","urlock","someuser","somepass",0,NULL,0) !=0);

Importing/exporting can be tricky but to point you in the right direction look into the mysqldump command.

1
  1. I believe the second parameter should be the host. If it is a local mySQL, the host is localhost.
  2. The default username is usually 'root'.

Try this:

(mysql_real_connect(conn,"localhost","urlock","","root",0,NULL,0) !=0);
1
  • Thank you, Tania. Still a little confused. New to this. My file is located here C:\FILEBLOCK\urlockCS.adp it was an Access 2010 file converted to MySQL if that makes any difference. I appreciate the help.
    – ME-dia
    Oct 14, 2011 at 20:45
0

Most (if not all) installations of MySQL should have default accounts. There should at least be a root account. http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html

-1

You'll need a CONNECTIONSTRING

SqlConnection con = new SqlConnection(connectionString);

con.Open();

If you add your database in visual studio under Dataconnections, you can see the connection string under properties

ADDED:

If its an sqllite db, you need to use an SQLCeConneciton

private static string connectionString = @"Data Source=path/to/the/database/db.sdf"; private static SqlCeConnection con = new SqlCeConnection(connectionString);

1
  • Thank you. I am using mySql 5.0
    – ME-dia
    Oct 14, 2011 at 20:06

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.