C#写代码需要从SQL中取出数据并存入TXT中并且存入的路径是网络参数,现在新建TXT都出错,望大神能帮忙解决
C#中报错错误1 应输入 class、delegate、enum、interface 或 struct C:\Users\ndcsh_admin\Desktop\SAP\文档\SAP01\SAP01\MainWindow.xaml.cs 12 40 SAP01
2 应输入标识符 C:\Users\ndcsh_admin\Desktop\SAP\文档\SAP01\SAP01\MainWindow.xaml.cs 15 39 SAP01
3 应输入类型、命名空间定义或文件尾 C:\Users\ndcsh_admin\Desktop\SAP\文档\SAP01\SAP01\MainWindow.xaml.cs 16 14 SAP01
4 未能找到类型或命名空间名称“?Attribute”(是否缺少 using 指令或程序集引用?) C:\Users\ndcsh_admin\Desktop\SAP\文档\SAP01\SAP01\MainWindow.xaml.cs 15 38 SAP01
代码如下
public static void ReadOrderData(string connectionString)
{
//要执行的Sql语句
string queryString = new SqlDataAdapter("sql查询语句", "server=服务器地址;database=数据库,user=用户名;pwd=密码");
using (SqlConnection connection = new SqlConnection( connectionString))
{
SqlCommand command = new SqlCommand( queryString, connection);
connection.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
using (StreanmWriter sw = new StreamWriter("D:\\test.txt"))
{
while (sdr.Read())
sw.Write("\\qu" + sdr[0].ToString()):
}
}
}
}