I searched through a lot but couldn't figure out how to do this. I am sure it is because of my being amateur in this field.
I am trying to build a web program for my students so that they can practice the foreign language more on their own. So, what I come up with is a showing a text in the target language and then asking student to read it. After a few tryings, I found out that every time creating a new practice page is taking too long, so I thought maybe I could just put the words or sentences into the database under unit1 or unit2 column, and the webpage will pull these datas and show them to students as practice questions.
This is how practice page looks like: practice page
as you see on the picture, in place of each [label] area, there would be a word/text.
This is how database look like: questions database
with all the research and everything, I could get until here
Code:
using System;
using System.Data.OleDb;
namespace language
{
public partial class exercise1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString =@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\inetpub\wwwroot\www\language\data2.accdb";
string queryString ="SELECT unit1 FROM questions";
try
{
using(OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbCommand command = new OleDbCommand(queryString, connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
while(reader.Read())
{
Label1.Text = reader.GetString(22).ToString();
Label3.Text = reader.GetString(23).ToString();
Label5.Text = reader.GetString(24).ToString();
Label7.Text = reader.GetString(25).ToString();
Label9.Text = reader.GetString(26).ToString();
}
reader.Close();
}
}
catch (Exception ex)
{
Response.Write("<script>alert('error error error')</script>");
}
}
}
This is how the code looks like now, I copied it from another question here, but again didn't work. I tried DataTable, couldn't make it work either. You help will be appreciated a lot. I am sorry for any irregularities with everything here.
Thank you for your help