หามาหลายวันแล้วค่ะ ยังไม่เจอเลย error ExecuteReader: Connection property has not been initialized.
มันมีปัญหาตั้งแต่ Connection ครับ ลอง Copy ทั้งหมดมาให้ดูหน่อยครับ
Date :
2012-03-18 08:23:33
By :
webmaster
ค่ะๆๆๆ ได้ค่ะ
Code (C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Drawing.Drawing2D;
using System.Diagnostics;
using BookRent.Class;
namespace BookRent
{
public partial class frmReturn : Form
{
public frmReturn()
{
InitializeComponent();
}
SqlConnection Conn;
//SqlCommand com;
//StringBuilder sb;
SqlDataReader dr;
DataTable dtMember;
SqlTransaction tr;
DateTime Today;
string CRentID = "";
string[] CurrentBook = new string[10];
Stopwatch sw = new Stopwatch();
//double ProcessTime;
//ToolStripLabel _ToolStripLabel = new ToolStripLabel();
private void frmReturn_Load(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
//lblBranch.BackColor = Color.FromArgb(0, 0, 0, 0);
lblFine.BackColor = Color.FromArgb(0, 0, 0, 0);
grbDetail.BackColor = Color.FromArgb(0, 0, 0, 0);
grbProductList.BackColor = Color.FromArgb(0, 0, 0, 0);
sw.Reset();
sw.Start();
string strConn;
strConn = DBConnString.strConn;
Conn = new SqlConnection();
if (Conn.State == ConnectionState.Open)
{
Conn.Close();
}
Conn.ConnectionString = strConn;
Conn.Open();
Today = DateTime.Today;
ClearAllData();
txtSearchMember.Focus();
sw.Stop();
}
private void ClearAllData()
{
lblNetFine.Text = "0";
txtSearchMember.Text = "";
lblFullName.Text = "";
// lblFineRateDiscount.Text = "0";
dgvMemberList.Visible = false;
dgvRent.DataSource = null;
dgvRentDetail.DataSource = null;
dgvBookList.Rows.Clear();
CRentID = "";
cmdCalculateNetFine.Enabled = false;
cmdExchange.Enabled = false;
cmdSave.Enabled = false;
}
Date :
2012-03-18 09:41:04
By :
Aubegaa
ส่วนนี้ คือ Class DBConnString
Code (C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BookRent.Class
{
public sealed class DBConnString
{
public static string strConn = "Data Source=.\\SQLExpress;Initial Catalog=dbBookRent;Integrated Security=True";
public static string UserName = "";
}
}
Date :
2012-03-18 09:44:40
By :
Aubegaa
Conn.Open(); ก่อนที่จะทำการอ่านครับผม
Date :
2012-03-18 17:47:22
By :
anucham
ค่ะ ขอบคุณค่ะ ตอนนี้ได้แล้วค่ะ ^^
Date :
2012-03-18 18:30:06
By :
Aubegaa
Load balance : Server 05