SqlDataReader reader = com.ExecuteReader();
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace pro3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string s = "server=.;database=SampleDb;integrated security=true;";
SqlConnection conn = new SqlConnection(s);
SqlCommand com = new SqlCommand();
String sql = " select Name as 课程名称,Name as 学生姓名, Score as 考试成绩 from (Student inner join ExamScore on Student.Id=ExamScore.StudentId)inner join Lesson on ExamScore.LessonId=Lesson.Id ";
textBox1.Text = sql;
= sql;
com.Connection = conn;
//
conn.Open();
SqlDataReader reader = com.ExecuteReader();
while (reader.Read()){
String Lname = (String)reader["Name"];
String Sname = (String)reader["Name"];
int Score=(int) reader["Score"];
}
reader.Close();
conn.Close();
}
}
}
*****问题: SqlDataReader reader = com.ExecuteReader(); “,”附近有错误。