如果数据库是SQL 添加引用:using System.Data.SqlClient;
如果你的数据库是直接建在vs里的话:
string connStr = @"Data Source = .\SQLEXPRESS; AttachDBfilename = |DataDirectory|\DBStudent.mdf; Integrated Security = True; User Instance = True";
//DBStudent.mdf是我的数据库名字,你改成你的数据库就行了:*.mdf;
using (SqlConnection conn = new SqlConnection(connStr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = ""; //你的操作
cmd.ExcuteNonQuery();
}
}
如果数据库是建在你电脑上的数据库里:
string connStr = @"Data Source = .; Initial Catalog = DBname(你的数据库名); Integrated Security = True";
其他一样
要添加引用,然后using System.Data.OracleClient;
provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=UserName;Data Source=DataBaseName;Extended Properties='';Password=Password
代码和其它数据库访问一样:
OracleConnection con = new OracleConnection(connectionString);
OracleCommand cmd = new OracleCommand("select * from KLCUSTOM_BOMS",conn);
con.Open();
OracleDataReader odr=cmd.ExecuteReader();
可惜没写过CE的程序,不知