I am currently working on a project where I need to submit a file path to a database, and be able to pull that path from the database as well.
Currently I am able to submit the path to the database and pull the data from the database, however the slashes in the path seem to be getting stripped from the string when I submit to the database.
How can I stop the \ from being stripped when submitting to the database and when pulling from the database?
Here is my save button event code:
private void btnSaveSettings_Click(object sender, EventArgs e)
{
string myConnection = "datasource=localhost;port=3306;username=username;password=password";
string Query = "insert into ephex_contcollections.Paths (toindex,indexed) values('" + this.txtToIndexPath.Text + "','" + this.txtIndexedPath.Text + "') ;";
MySqlConnection myConn = new MySqlConnection(myConnection);
MySqlCommand cmdDB = new MySqlCommand(Query, myConn);
MySqlDataReader myReader;
try
{
myConn.Open();
myReader = cmdDB.ExecuteReader();
MessageBox.Show("Save Successful");
while (myReader.Read())
{
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} //close save button event
The string that I am submitting to the database look like this while in the text box:
C:\Users\Meta\Desktop\Alpha
But they submit to the database like this:
C:UsersMetaDesktopAlpha
Thanks in advance (I am new to using MySQL databases with C# and am rusty on my C# as well).