User516094431 posted
int rows = 0;
protected void Page_Load(object sender, EventArgs e)
{
string connString = ConfigurationManager.ConnectionStrings["xls"].ConnectionString;
// Create the connection object
OleDbConnection oledbConn = new OleDbConnection(connString);
try
{
// Open connection
oledbConn.Open();
// Create OleDbCommand object and select data from worksheet Sheet1
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
// Create new OleDbDataAdapter
OleDbDataAdapter oleda = new OleDbDataAdapter();
oleda.SelectCommand = cmd;
// Create a DataSet which will hold the data extracted from the worksheet.
DataSet ds = new DataSet();
// Fill the DataSet from the data extracted from the worksheet.
oleda.Fill(ds, "Employees");
if(ds.Table[0].Rows.Count > 0)
{
txtbox1.Text = ds.Table[0].Row[rows][0];
txtbox2.Text = ds.Table[0].Row[rows][1];
txtbox3.Text = ds.Table[0].Row[rows][2];
txtbox4.Text = ds.Table[0].Row[rows][3];
txtbox5.Text = ds.Table[0].Row[rows][4];
rows ++;
}
}
catch
{
}
finally
{
// Close connection
oledbConn.Close();
}
}
protected void btnNext_Click(object sender, EventArgs e)
{
insert data into MS see below link:
http://social.msdn.microsoft.com/Forums/en-US/aa1e768b-b3bb-4a99-8902-4739ce1c9c82/inserting-data-into-ms-access-using-c
if(ds.Table[0].Rows.Count > 0)
{
txtbox1.Text = ds.Table[0].Row[rows][0];
txtbox2.Text = ds.Table[0].Row[rows][1];
txtbox3.Text = ds.Table[0].Row[rows][2];
txtbox4.Text = ds.Table[0].Row[rows][3];
txtbox5.Text = ds.Table[0].Row[rows][4];
rows ++;
}
}