1 private DataSet GetCollection()
2 {
3 DataSet ds=new DataSet();
4 string strCon,strCmm;
5 // strCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\irms\\tmp\\irsbd.xls;Extended Properties=Excel 8.0;";
6 strCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("tmp\\irsbd.xls")+";Extended Properties=Excel 8.0;";
7 strCmm="select distinct * from [Sheet1$]";
8 OleDbConnection oleCnn=new OleDbConnection(strCon);
9 OleDbCommand oleCmm=new OleDbCommand(strCmm,oleCnn);
10 OleDbDataAdapter oleDa=new OleDbDataAdapter(oleCmm);
11 oleDa.Fill(ds,"irsbd");
12
13 return ds;
14
15 }
16
17 private void PutData(DataSet ds)
18 {
19 string strCon=Application["strCon"].ToString();
20 string strSql="select top 1 * from irsbd";
21 DataSet myDs=new DataSet();
22 SqlDataAdapter da=new SqlDataAdapter(strSql,strCon);
23 da.Fill(myDs,"irsbd");
24 for(int i=0;i<ds.Tables[0].Rows.Count;i++)
25 if(ds.Tables[0].Rows[i]["sbdno"].ToString().Trim()!="")
26 {
27 DataRow dr=myDs.Tables[0].NewRow();
28 DataRow dr1=ds.Tables[0].Rows[i];
29 dr["sbdno"]=dr1["sbdno"];
30 dr["sbdnm"]=dr1["sbdnm"];
31 dr["sbdpd"]=dr1["sbdno"];
32 dr["sbdit"]=dr1["sbdit"];
33 dr["sbddt"]=dr1["sbddt"];
34 dr["sbdco"]=tbCo.Text.Trim();
35
36 dr["sbdel"]=DateTime.Today;
37 dr["sbdcs"]=0;
38 dr["sbdas"]=0;
39 dr["sbdps"]=0;
40 dr["sbdcs1"]=0;
41 dr["sbdcs2"]=0;
42 dr["sbdcs3"]=0;
43 dr["sbdcs4"]=0;
44 dr["sbdas1"]=0;
45 dr["sbdas2"]=0;
46 dr["sbdas3"]=0;
47 dr["sbdas4"]=0;
48
49 myDs.Tables[0].Rows.Add(dr);
50 }
51
52 SqlCommandBuilder sqlCb=new SqlCommandBuilder(da);
53
54 da.Update(myDs,"irsbd");
55 myDs.AcceptChanges();
56 }
2 {
3 DataSet ds=new DataSet();
4 string strCon,strCmm;
5 // strCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\irms\\tmp\\irsbd.xls;Extended Properties=Excel 8.0;";
6 strCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("tmp\\irsbd.xls")+";Extended Properties=Excel 8.0;";
7 strCmm="select distinct * from [Sheet1$]";
8 OleDbConnection oleCnn=new OleDbConnection(strCon);
9 OleDbCommand oleCmm=new OleDbCommand(strCmm,oleCnn);
10 OleDbDataAdapter oleDa=new OleDbDataAdapter(oleCmm);
11 oleDa.Fill(ds,"irsbd");
12
13 return ds;
14
15 }
16
17 private void PutData(DataSet ds)
18 {
19 string strCon=Application["strCon"].ToString();
20 string strSql="select top 1 * from irsbd";
21 DataSet myDs=new DataSet();
22 SqlDataAdapter da=new SqlDataAdapter(strSql,strCon);
23 da.Fill(myDs,"irsbd");
24 for(int i=0;i<ds.Tables[0].Rows.Count;i++)
25 if(ds.Tables[0].Rows[i]["sbdno"].ToString().Trim()!="")
26 {
27 DataRow dr=myDs.Tables[0].NewRow();
28 DataRow dr1=ds.Tables[0].Rows[i];
29 dr["sbdno"]=dr1["sbdno"];
30 dr["sbdnm"]=dr1["sbdnm"];
31 dr["sbdpd"]=dr1["sbdno"];
32 dr["sbdit"]=dr1["sbdit"];
33 dr["sbddt"]=dr1["sbddt"];
34 dr["sbdco"]=tbCo.Text.Trim();
35
36 dr["sbdel"]=DateTime.Today;
37 dr["sbdcs"]=0;
38 dr["sbdas"]=0;
39 dr["sbdps"]=0;
40 dr["sbdcs1"]=0;
41 dr["sbdcs2"]=0;
42 dr["sbdcs3"]=0;
43 dr["sbdcs4"]=0;
44 dr["sbdas1"]=0;
45 dr["sbdas2"]=0;
46 dr["sbdas3"]=0;
47 dr["sbdas4"]=0;
48
49 myDs.Tables[0].Rows.Add(dr);
50 }
51
52 SqlCommandBuilder sqlCb=new SqlCommandBuilder(da);
53
54 da.Update(myDs,"irsbd");
55 myDs.AcceptChanges();
56 }