问题是:
1 - 为什么当我想在查询行中使用值TargetPoint
时,它总是返回0.
2 - 我有一个表格(让我们说表格1),用户选择一些信息,并获得一些其他信息并插入相同的表格(表格1),用户将被引导到另一个表格回答一些问题并再次回到表单1.问题是当用户回到表单时,这些信息被删除,他需要再次插入这些信息。
任何帮助都会很棒。
namespace LLL
{
public partial class LearnerForm : Form
{
public string TargetPoint;
private OleDbConnection connection = new OleDbConnection();
public LearnerForm()
{
InitializeComponent();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\ds.accdb";
lbl_welcome.Text = "Welcome " +Login.name +"!";
txtbox_startsubject.Text = diagnostic_evaluation.startpoint;
}
private void label1_Click(object sender, EventArgs e)
{
//MessageBox.Show("Welcome" + txtbox_user.Text);
}
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
//static string TargetPoint = null;
public void btn_start_Click(object sender, EventArgs e)
{
this.Hide();
diagnostic_evaluation F1 = new diagnostic_evaluation();
F1.Show();
//string TargetPoint = null;
if (checkBox1.Checked)
{
TargetPoint = "A";
}
if (checkBox2.Checked)
{
TargetPoint = "B";
}
if (checkBox3.Checked)
{
TargetPoint = "C";
}
if (checkBox4.Checked)
{
TargetPoint = "D";
}
if (checkBox5.Checked)
{
TargetPoint = "E";
}
if (checkBox6.Checked)
{
TargetPoint = "F";
}
if (checkBox7.Checked)
{
TargetPoint = "G";
}
if (checkBox8.Checked)
{
TargetPoint = "H";
}
if (checkBox9.Checked)
{
TargetPoint = "I";
}
if (checkBox10.Checked)
{
TargetPoint = "J";
}
}
private void btn_recom_Click(object sender, EventArgs e)
{
DataTable InteractionData = new DataTable();
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "SELECT * FROM MainData WHERE ID IN (SELECT T1.ID FROM MainData AS T1 INNER JOIN MainData AS T2 ON T1.ID = T2.ID WHERE (T1.Lesson='" + txtbox_startsubject.Text + "' AND T2.Lesson='"+TargetPoint+"') GROUP BY T1.ID)";
OleDbDataAdapter maindata = new OleDbDataAdapter(command);
DataTable interaction = new DataTable();
DataTable recommendation = new DataTable();
maindata.Fill(interaction);
dataGridView1.DataSource = interaction;
connection.Close();
}
}
}