如何连接到 LibreOffice Base 数据库?
How do I connect to a LibreOfficeBase-database?
我希望这不是转贴,但我还找不到答案。
如何连接到 C# 中的 LibreOfficeBase 数据库?我没有 MS Access,所以我只有 Libre。到目前为止,这是我写的:
private void add_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
OleDbDataReader reader;
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
"Data Source=C:\Users\user\Desktop\data.odb;";
cmd.Connection = con;
cmd.CommandText = "INSERT INTO data(name, age)" +
"VALUES('" + FamilyName.Text + "', '" + Age.Text +"')";
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Close();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
我的数据库名为 data.odb,当然它不起作用,因为此方法适用于 .accdb 文件。我如何处理 .odb 文件?
odb是openoffice数据库。存在用于处理 odb 文件的 MySQL 连接器,请参见此处 https://wiki.openoffice.org/wiki/Database/Drivers/MySQL_Native/1.0。
您可能还想查看 OpenOffice 文档 https://wiki.openoffice.org/wiki/Database#Developer which says how to connect to MS Access https://wiki.openoffice.org/wiki/Connecting_to_Microsoft_Access
我希望这不是转贴,但我还找不到答案。 如何连接到 C# 中的 LibreOfficeBase 数据库?我没有 MS Access,所以我只有 Libre。到目前为止,这是我写的:
private void add_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
OleDbDataReader reader;
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
"Data Source=C:\Users\user\Desktop\data.odb;";
cmd.Connection = con;
cmd.CommandText = "INSERT INTO data(name, age)" +
"VALUES('" + FamilyName.Text + "', '" + Age.Text +"')";
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Close();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
我的数据库名为 data.odb,当然它不起作用,因为此方法适用于 .accdb 文件。我如何处理 .odb 文件?
odb是openoffice数据库。存在用于处理 odb 文件的 MySQL 连接器,请参见此处 https://wiki.openoffice.org/wiki/Database/Drivers/MySQL_Native/1.0。
您可能还想查看 OpenOffice 文档 https://wiki.openoffice.org/wiki/Database#Developer which says how to connect to MS Access https://wiki.openoffice.org/wiki/Connecting_to_Microsoft_Access