正在加载图片...
string strCon =@"Data Source =.Initial Catalog TestDB;Integrated Security True;";string strsql ="update JBQK set Age=DATEDIFF(yyyy,BirthDay,getDate())"; SqlConnection sqlConn new SqlConnection(strCon);try sqlConn.Open(); ∥打开连接 SqlCommand cmd; if(sqlConn.State==ConnectionState.Open) cmd new SqlCommand(strsql,sqlConn); cmd.ExecuteNonQuery(); MessageBox.Show("更新成功"); } } catch(Exception ex) MessageBox.Show(ex.Message); 9 9 string strCon =@"Data Source = .; Initial Catalog = TestDB; Integrated 修改数据 Security = True;";string strsql = "update JBQK set Age=DATEDIFF(yyyy,BirthDay,getDate() ) "; SqlConnection sqlConn = new SqlConnection(strCon); try { sqlConn.Open(); // 打开连接 SqlCommand cmd; if (sqlConn.State == ConnectionState.Open) { cmd = new SqlCommand(strsql, sqlConn); cmd.ExecuteNonQuery(); MessageBox.Show("更新成功"); } } catch (Exception ex) { MessageBox.Show(ex.Message); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有