我困在簡單的數據讀取器問題中。dataReader reader = cmd.executereader()不工作
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在目前情況下不會退出)的錯誤.....
我已經嘗試過和連接,但無法正常工作後,創建對象。
與'CommandType.TableDirect'你不寫選擇 –