我为我的应用程序创建了一个通用数据库处理程序类。
我使用的是本地数据库,所以SqlCeConnection这里使用了类。
我想做的是测试连接字符串是否有效,所以在我执行之前更新用户的连接状态connection.Open();
让我们说
 SqlCeConnection conn = new SqlCeConnection(connectionString);
 //so far we have only created the connection, but not tried to open it
 //Would be nice to update the UI to say that conn is OK
 conn.testConnection();
 conn.Open();
我正在考虑编写一种尝试连接的方法,open我close的想法是正确的还是有更好的方法。