數(shù)據(jù)的查詢: private void FullTab() { SqlConnection con1 = new SqlConnection();//創(chuàng)建數(shù)據(jù)庫(kù)庫(kù)鏈接 try { String con = "server=.;database=common_wjdl;uid=sa;pwd=db2008mima";//定義數(shù)據(jù)庫(kù)連接信息 con1.ConnectionString = con; con1.Open();//打開(kāi)數(shù)據(jù)庫(kù) String sql = "select * from Fileuploaded";//創(chuàng)建語(yǔ)句查詢所有數(shù)據(jù) SqlDataAdapter ada1 = new SqlDataAdapter(sql, con);//SqlDataAdapter 對(duì)象。 用于填充DataSet (數(shù)據(jù)集)。 DataSet myset = new DataSet(); SqlCommand cmd = con1.CreateCommand();//創(chuàng)建數(shù)據(jù)庫(kù)命令 cmd.CommandText = sql; SqlDataReader reader = cmd.ExecuteReader(); //從數(shù)據(jù)庫(kù)中讀取數(shù)據(jù)流存入reader中 } catch (SqlException ee1) { Console.WriteLine(ee1.Message);//打印異常信息 } catch (IndexOutOfRangeException ee2) { Console.WriteLine(ee2.Message);//打印異常信息 } } 數(shù)據(jù)的插入:(大致都一樣,只需修改SQL語(yǔ)句就行) String con = "server=.;database=common_wjdl;uid=sa;pwd=db2008mima";//定義數(shù)據(jù)庫(kù)連接信息 con1.ConnectionString = con; con1.Open();//打開(kāi)數(shù)據(jù)庫(kù) String sql = "insert into Fileuploaded (FileID,FileName,FilePath,QRCodePath,FileSuffix) Values('"+fileNameSave+"','"+fileName+"','"+filePath+"','"+filePath+"','"+fileSuffix+"')";//創(chuàng)建語(yǔ)句向數(shù)據(jù)庫(kù)插入數(shù)據(jù) SqlCommand cmd = con1.CreateCommand();//創(chuàng)建數(shù)據(jù)庫(kù)命令 cmd.CommandText = sql; cmd.ExecuteNonQuery();
成都創(chuàng)新互聯(lián)公司是專業(yè)的麻章網(wǎng)站建設(shè)公司,麻章接單;提供網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行麻章網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!