首页 文章

c#使用ODBC sql在FileMaker表中插入数据

提问于
浏览
0

我创建了一个应用程序,它将在filemaker数据库中插入值 .

我使用ODBC创建连接,它工作正常,插入也工作正常 .

插入记录后,查找字段值不会自动更新 .

static void Main(string[] args)
        {

            OdbcConnection conn = null;
            OdbcCommand cmd = null;
            OdbcDataAdapter da = new OdbcDataAdapter();
            string temp = "";

            try
            {
                //DRIVER=FileMaker ODBC;
                conn = new OdbcConnection("DSN=SecureDSN;UID=***;PWD=***");
                conn.Open();

                Console.WriteLine(conn.State);

                if (conn.State == System.Data.ConnectionState.Open)
                {
                    cmd = conn.CreateCommand();

                    Console.WriteLine("Input value text");

                    string code = Console.ReadLine();

                    cmd.CommandText = "INSERT INTO MyTable(Field1) VALUES ('test')";
                    cmd.CommandType = System.Data.CommandType.Text;

                    cmd.ExecuteNonQuery();


                    cmd.Dispose();


                    cmd = conn.CreateCommand();
                    cmd.CommandText = "SELECT * FROM MyTable";
                    cmd.CommandType = System.Data.CommandType.Text;
                    DataTable dt = new DataTable();
                    da.SelectCommand = cmd;
                    da.Fill(dt);

                    if (dt.Rows.Count > 0)
                    {
                        int fCount = dt.Rows.Count;
                        Console.WriteLine(fCount);

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            Console.WriteLine("gBarcode=" + Convert.ToString(dt.Rows[i]["gBarCode"]));
                            Console.WriteLine("Boolean=" + Convert.ToString(dt.Rows[i]["Boolean"]));
                            Console.WriteLine("cBoolean=" + Convert.ToString(dt.Rows[i]["cBoolean"]));
                        }
                    }

                    da.Dispose();
                    cmd.Dispose();
                    conn.Close();
                }



            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Press any key to stop...");
            Console.ReadKey();
        }
    }

这工作正常,但我无法获取MyTable中查找值的值 .

当我在filemaker表单中输入值时,将更新布尔字段的值 . 为什么它不是从SQL查询计算的 . 请让我知道解决方案 .

1 回答

  • 0

    如果计算字段中没有任何关系值,则它可以工作,但是当我们有关系值时,它返回空 .

相关问题