The dataadapter.selectcommand property needs to be initialized lỗi năm 2024

Every time I pressed the "Test SQL" button named btnTest, I recieve the error message "Fill: SelectCommand.Connection has not been initialized", although the line "resultsAdapter.SelectCommand = resultsCommand;" is correct. How do I resolve this issue?

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confindential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

  • The dataadapter.selectcommand property needs to be initialized lỗi năm 2024
  • Diễn đàn
  • Lập trình
  • Các ngôn ngữ lập trình
  • .NET
  • Giúp mình fix dùm lỗi này....đang cần gấp

The dataadapter.selectcommand property needs to be initialized lỗi năm 2024

  1. Giúp mình fix dùm lỗi này....đang cần gấp
    Mình đang làm 1 form hiển thị chi tiết thông tin người dùng thông qua database trong SQL,nó là cái datagridview,viết bằng n-layer.Đoạn code StudentForm_Load của mình báo lỗi như sau: SelectCommand.Connection property has not been initialized

    đây là các đoạn code liên quan:

public SqlDataAdapter ExecuteQuery_GetAdapter(String SPName, List<SqlParameter> paramList) { cmd = new SqlCommand(); PrepareCommand(cmd, SPName, paramList); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; CloseConnect(); return da; }

public SqlDataAdapter getAllStudent() { DBHelper helper = new DBHelper(); SqlParameter param; SqlDataAdapter da = new SqlDataAdapter(); List<SqlParameter> paramList= new List<SqlParameter>(); return helper.ExecuteQuery_GetAdapter("st_getAllStudent", paramList); }

private void StudentForm_Load(object sender, EventArgs e) { da = stdBLL.getAllStudent(); da.Fill(ds, "Students"); dt = ds.Tables["Students"]; Display();

}

public void Display() { dataGridView1.DataSource = dt; }

Mong mọi người giúp đỡ nhé

Nó báo lỗi chỗ dòng Fill ý...=.=! chán đời quá k bik sao nữa.... Được sửa bởi zZzPC-NODzZz lúc 21:24 ngày 08-09-2010

-
  1. > Open Connect ???????????????????????? -
  2. > đây public DBHelper() { if (conn == null || conn.State == ConnectionState.Closed) InitConnection(); } public void InitConnection() { conn = new SqlConnection("Data Source = HIEU;Database = Student;Integrated Security = SSPI"); conn.Open(); } public void CloseConnect() { if (conn.State == ConnectionState.Open)

conn.Close(); }

Có vẻ như chả ai code n-layer mấy!!!!chả thấy ai fix dùm Được sửa bởi zZzPC-NODzZz lúc 23:06 ngày 08-09-2010

-
  1. > bạn ơi theo tơ hiểu thì cái InitConnection() bạn lên thay void bằng Sqlconnect sau đó gán cho SelectCommand.Connection vì trong mấy hàm trên tớ ko thấy hàm bạn mở kết nỗi chỗ nào. private static SqlConnection conn; public static SqlConnection InitConnection() { conn = new SqlConnection("Data Source = localhost;Database = TESTLINQ;Integrated Security = SSPI"); conn.Open(); return conn; }

[=========> Bổ sung bài viết <=========]

Bạn đã mở kết nối nhưng lại không trỏ kết nối cho selectcommond Được sửa bởi hoangvansang lúc 11:13 ngày 09-09-2010Reason: Bổ sung bài viết

-

Bookmarks

Bookmarks

Quy định

  • Bạn không thể tạo chủ đề mới
  • Bạn không thể trả lời bài viết
  • Bạn không thể gửi file đính kèm
  • Bạn không thể sửa bài viết của mình
  • BB code is On
  • Smilies are On
  • code is On
  • code is On
  • HTML code is Off

Quy định DDTH.com