[問題]資料庫新手(已爬文)
今天依照範例,
在連接資料庫與c#,
不過不能run,
他是顯示遺漏偵錯目標
請建置專案後重試,
不過我連建置都不能建置,
所以想請問一下各位大大我的問題在哪裡ㄚ= ="
萬分感激<(_ _)>
隨文附上程式碼
using System.Data.SqlClient;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string connStr,selectCmd;
connStr = "Server=localhost;dataDB;uid=sa;pwd=123456;";
SqlConnection myConnection = new SqlConnection(connStr);
selectCmd = "SELECT * FROM MEMBER";
SqlConnection conn;
SqlCommand cmd;
SqlDataReader reader;
conn = new SqlConnection(connStr);
conn.Open();
cmd = new SqlCommand(selectCmd, conn);
reader = cmd ExecuteReader();
for (int i = 0; i < reader.FieldCount; i++)
{
richTextBox1.Text += reader.GetName(i) + "\t";
}
richTextBox1.Text +="\n\n";
while (reader.Read())
{
for(int j = 0; j < reader.FieldCount; j++)
{
richTextBox1.Text += reader[j] + "\t";
}
richTextBox1.Text += "\n";
}
reader.Close();
conn.Close();
}
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.43.58
推
10/05 20:13, , 1F
10/05 20:13, 1F
→
10/06 02:06, , 2F
10/06 02:06, 2F
→
10/06 07:55, , 3F
10/06 07:55, 3F
→
10/06 15:25, , 4F
10/06 15:25, 4F
→
10/06 15:26, , 5F
10/06 15:26, 5F