我使用xampp作为我的sql数据库服务器。
我试图连接到它,但它没有工作。
我是C#的新手
这是我的代码
namespace InventoryManagement
{
public partial class Form1 : Form
{
public string dbconnect = "Server=127.0.0.1;User=root@localhost;password=;database=inventory;";
}
private void button3_Click(object sender, EventArgs e)
{
SqlConnection connect = new SqlConnection();
connect.ConnectionString = dbconnect;
connect.Open();
if (connect.State == ConnectionState.Open)
{
MessageBox.Show("connected");
}
}
}
任何帮助深表感谢。
谢谢。
也许你应该试试这个
public string conn = "server=localhost; user id = root; database=inventory";