[英]How do I connect to a LibreOfficeBase-database?
I hope this isn't a repost but I couldn't find an answer yet. 我希望这不是转发,但我找不到答案。 How can I connect to a LibreOfficeBase-database in C#? 如何在C#中连接到LibreOfficeBase数据库? I don't have MS Access, that's why I only have Libre. 我没有MS Access,这就是为什么我只有Libre。 So far, this is what I wrote: 到目前为止,这是我写的:
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);
}
}
My database is called data.odb and of course it isn't working, because this method is for .accdb files. 我的数据库称为data.odb,它当然不起作用,因为此方法适用于.accdb文件。 What do I do for .odb files? .odb文件该怎么办?
odb is openoffice database. odb是openoffice数据库。 There is a MySQL connector present for working with odb file see here https://wiki.openoffice.org/wiki/Database/Drivers/MySQL_Native/1.0 . 存在一个用于处理odb文件的MySQL连接器,请参见https://wiki.openoffice.org/wiki/Database/Drivers/MySQL_Native/1.0 。
Also you might want to go through OpenOffice documentation https://wiki.openoffice.org/wiki/Database#Developer which says how to connect to MS Access https://wiki.openoffice.org/wiki/Connecting_to_Microsoft_Access 另外,您可能需要浏览OpenOffice文档https://wiki.openoffice.org/wiki/Database#Developer ,其中说明了如何连接到MS Access https://wiki.openoffice.org/wiki/Connecting_to_Microsoft_Access
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.