110,533
社区成员
发帖
与我相关
我的任务
分享
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=192.168.0.1;Initial Catalog=database;Persist Security Info=True;User ID=sa;Password=abcd";
try
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandTimeout = 0;
cmd.CommandText = " select top 1 * from address";
SqlDataReader reader = cmd.ExecuteReader();
int i = 0;
while (reader.Read())
{
i++;
kstx_time.Text = reader[0].ToString();
txwc_time.Text = reader[1].ToString();
hgyh_time.Text = reader[2].ToString();
yhwc_time.Text = reader[3].ToString();
zxwc_time.Text = reader[4].ToString();
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
zxwc_time.Text = ex.Message;
}
using System.Data.SqlServerCe;
// open the database.
cn = new SqlCeConnection("Data Source=\\Storage\\prac3.sdf");
cn.Open();
//Create the structure of the database using SQL statements.
// Create the Titles table.
String SQL = " "; //your sql order
SqlCeCommand cmd = new SqlCeCommand(SQL, cn);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();