RiggsFolly Wrote:
-------------------------------------------------------
> Yes that was me.
>
> Am I right in thinking you are using SQLServer?
>
> Can you show your SQLServer connection parameters
> please.
Sorry to dissapoint but I'm not using any SQLServer, i just have MySQL which came with wamp
All i have is what i downloaded, and that's Wamp, then i went and downloaded filezilla server in order to get ftp up and running. That's about it.
//These lines go to a C# class where it inserts to the database given //
E.g. MySQLClient sqlClient = new MySQLClient("host", "database", "user", "password " );
The SQL code posted above:
sqlClient.Insert("images", "title, alternative, type, slider, image", "'none', 'none', '1', '0', 'image.jpg' " ) ;
// To C# class //
public void Insert(string table, string column, string value)
{
//Insert values into the database.
//Example: INSERT INTO names (name, age) VALUES('John Smith', '33')
//Code: MySQLClient.Insert("names", "name, age", "'John Smith, '33'" );
string query = "INSERT INTO " + table + " (" + column + " ) VALUES (" + value + " ) ";
try
{
if (this.Open())
{
//Opens a connection, if successful; run the query and then close the connection.
MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.ExecuteNonQuery();
this.Close();
}
}
catch (Exception ex)
{
MessageBox.Show("An error occurred: " + ex); //However this does not work for some reason.
}
return;
}
//C# Class //
//EDIT//
Forgot to add the constructor:
public MySQLClient(string hostname, string database, string username, string password)
{
conn = new MySqlConnection("host=" + hostname + ";database=" + database +";username=" + username +";password=" + password +";" );
}
Do i have to add a port number to the conn string for it to work for my friend?
//EDIT//
So It's almost like a PHP script to insert into the database.
Could it be that he tries to insert into a database which doesn't exist because he doesn't have a database on his pc?
If so, how would it be possible to send it to my server on my pc?
Edited 4 time(s). Last edit at 01/02/2015 08:07PM by JimSundqvist.