Hello, I was trying to connect a MySQL database to a windows form and I received this error: System.ArgumentException: 'Keyword not supported: 'host'.'
I looked online and I'm not exactly sure how to fix it without going to app config files etc, and doing large scale changes. Does anybody have any experience with this error or any knowledge on how to remedy the situation? Here is a code snippet of what I'm working with, keep in mind I am just learning to work with databases.
using System;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace savetodatabasepractice
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = "User Id=XXXXXX;Host=localhost;Database=XXXXXX";
SqlCommand insertCommand = new SqlCommand("INSERT INTO tbl_newdata (ID, Temperature, Humidity) VALUES (1, 72, 34)", conn);
}
}
}
}
Thanks again for any help or insight!
I looked online and I'm not exactly sure how to fix it without going to app config files etc, and doing large scale changes. Does anybody have any experience with this error or any knowledge on how to remedy the situation? Here is a code snippet of what I'm working with, keep in mind I am just learning to work with databases.
using System;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace savetodatabasepractice
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = "User Id=XXXXXX;Host=localhost;Database=XXXXXX";
SqlCommand insertCommand = new SqlCommand("INSERT INTO tbl_newdata (ID, Temperature, Humidity) VALUES (1, 72, 34)", conn);
}
}
}
}
Thanks again for any help or insight!