私は、4D データベースから MSSQL 構造への 1 回限りの移行を任されました。ODBC アドミニストレーターでデータソースをセットアップしましたが、問題なく接続できました。
Visio でスキーマを「リバース エンジニアリング」したので、テーブル間の関係を視覚的に把握し、スキーマに適合するように 4D データを再構築する方法を計画しました。これは 1 回限りの実行であるため、単純なコンソール アプリケーションを作成しました。データ ソースへの接続を確立できますが、何かを実行するとすぐに、接続がドロップまたは無効になります。
System.Data.Odbc.OdbcConnection conn =
new System.Data.Odbc.OdbcConnection("Dsn=4D v12 datasource");
try
{
conn.Open();
Console.WriteLine("Status of Connection:" + conn.State.ToString());
//Here it says the connection to the DB is open and ready for action
Console.ReadLine();
//pause to visually confirm the connection is open
OdbcCommand com = new OdbcCommand("SELECT * FROM ATable", conn);
com.CommandType = CommandType.Text;
Console.Write(com.ExecuteNonQuery());
//Right here it blows up and closes the connection
}
また、データセットとデータアダプターで何かをしようとしましたが、役に立ちませんでした。
System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection("Dsn=4D v12 datasource");
try
{
conn.Open();
Console.WriteLine("Status of Connection:" + conn.State.ToString());
Console.ReadLine();
OdbcCommand com = new OdbcCommand("SELECT * FROM ATable", conn);
com.CommandType = CommandType.Text;
//Also tried using data sets and data adapters
DataSet dsTest = new DataSet();
OdbcDataAdapter dataAdapter = new OdbcDataAdapter(com);
//but right at this line the connection suddenly disconnects
dataAdapter.Fill(dsTest);
}
catch (Exception e)
{
Console.WriteLine("Failure:" + e.Message.ToString());
// the exception message reads simply connection has been disabled.
Console.WriteLine("Status of Connection: " + conn.State.ToString());
Console.ReadLine();
}
finally
{
Console.Write("Closing connection.");
conn.Close();
Console.Write(".");
conn.Dispose();
Console.WriteLine(".");
Console.WriteLine("Connection Closed and Disposed");
Console.ReadLine();
}
私はこれと同じ問題を抱えている人を探してみましたが、私が見つけたドキュメントはほとんどなく、この点に関してはあまり役に立ちませんでした。4D 製品でのクエリの実行に関する情報は豊富にありますが、デジタル デバイドを越えたものではありません。経験者の方アドバイスお願いします。熱心な読者の皆様、お時間を割いていただきありがとうございます。