为了得到一个列的数据类型我使用下面的代码在C#SQLite typeof()是否也适用于SQL?
System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("Data Source=C:\\Users\\SaMax\\Documents\\CustomersDB.s3db; Version=3; FailIfMissing=True;");
System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand("select typeof(Column_Name) from Table_Name;");
cmd.Connection = con;
try
{
con.Open();
string str = cmd.ExecuteScalar().ToString();
con.Close();
MessageBox.Show(str);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
它的工作原理。但是我想知道是否可以,并且还可以使用SQL和MySql。
我正在此查询仅仅是为了得到返回的字符串指定列 的数据类型。 – samaxI92
好的。然后,您将不得不为每个查询的数据库类型更改SQL。 – Vache
谢谢你的回答。最后一个问题是:任何替代函数 sqlite typeof()在sql中存在,所以我可以对大多数数据库使用相同的查询? – samaxI92