繁体   English   中英

如何连接到LibreOfficeBase数据库?

[英]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 ,其中说明了如何连接到MS Access https://wiki.openoffice.org/wiki/Connecting_to_Microsoft_Access

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM