【发布时间】:2016-02-18 00:48:28
【问题描述】:
我陷入了简单的数据读取器问题。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.Sql;
public void proName(string str)
{
SqlDataReader reader;
using (SqlConnection sqlcon = new SqlConnection(constr))
{
string proId = textBox3.Text;
SqlCommand sqlcmd = new SqlCommand("SELECT proName FROM products where proId = proId;", sqlcon);
sqlcmd.CommandType = CommandType.TableDirect;
reader = cmd.executereader();
}
}
它在 cmd / 命令下显示错误(名称 cmd 不会在当前上下文中退出).....
我尝试在连接前后创建对象,但没有成功。
【问题讨论】:
-
with
CommandType.TableDirect你不写选择
标签: c# sql .net winforms visual-studio-2012