110,825
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
SqlConnection SqlCon = new SqlConnection("Data Source=;Database=AAA;User id=sa;pwd=SQL4567");
SqlCon.Open();
string SqlStr="SELECT * FROM Table_1 WHERE 班级=1班";
SqlCommand SqlCmd = new SqlCommand(SqlStr, SqlCon);
SqlDataReader SqlRd = SqlCmd.ExecuteReader();
while (SqlRd.Read())
{
Console.WriteLine(SqlRd.GetString());
}
SqlCon.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int i = 0;
SqlConnection SqlCon = new SqlConnection("Data Source=;Database=AAA;User id=sa;pwd=SQL4567");
SqlCon.Open();
string SqlStr="SELECT * FROM Table_1 WHERE 班级='1'";
SqlCommand SqlCmd = new SqlCommand(SqlStr, SqlCon);
SqlDataReader SqlRd = SqlCmd.ExecuteReader();
while (SqlRd.Read())
{
while (SqlRd[i] != NULL)
{
Console.Write(SqlRd[i].ToString() + " ");
i++;
}
}
Console.WriteLine();
SqlCon.Close();
}
}
}