public void Sendmassage(string email) { DataTable tb; bool ex;//判断数据库操作是否成功 string sql;//数据库操作语句 string str;//数据库连接参数 str = "Server=YourSQLServer;user id=sa;password=;initial catalog=Northwind;Connect Timeout=30"; DataBaseAccess st = new DataBaseAccess(str); sql = "select * from 视图 where sort=0"; tb = st.GetDataTable(sql); string from = tb.Rows[0][0].ToString(); string password = tb.Rows[1][0].ToString(); MailAddress MessageFrom = new MailAddress(from); string MessageTo = email; string MessageSubject = boot.m_massagetitle; string MessageBody = boot.m_massage; if (Send(MessageFrom, MessageTo, MessageSubject, MessageBody,password)) { //MessageBox.Show("OK"); } else { //MessageBox.Show("NO"); } //根据获得邮箱将信息按照固定格式发送 }
private void bindGrid() { string connString = "Data Source=localhost;Initial Catalog=webinf;Integrated Security=SSPI;"; DataBaseAccess dbs = new DataBaseAccess(connString); String Sqlstring = "select * from Staff"; //string Sqlstring2 = "select * from Customers"; DataTable myds = dbs.GetDataTable(Sqlstring); //DataSet myds1 = dbs.GetDataSet(Sqlstring2); GridView1.DataSource = myds; GridView1.DataBind(); //GridView2.DataSource = myds1; //GridView2.DataBind(); }
public void Getsolution(int sort,string massage,string massagetitle) { bool exs; Cmassageload boot = new Cmassageload(sort, massage, massagetitle); exs=boot.Savemassage(sort,massage,massagetitle); if (exs) { //MessageBox.Show("SAVEOK"); } else { //MessageBox.Show("SAVENO"); } Cmassagesend sd = new Cmassagesend(); DataTable tb; bool ex;//判断数据库操作是否成功 string sql;//数据库操作语句 string str;//数据库连接参数 str = "Server=YourSQLServer;user id=sa;password=;initial catalog=Northwind;Connect Timeout=30"; DataBaseAccess st = new DataBaseAccess(str); sql = "select * from 视图 where sort=boot.sort"; tb = st.GetDataTable(sql); for (int i = 0; i <= tb.Rows.Count; i++) { // email = tb.Row[0][i]; // sd.Sendmassage(email); } }