question

NyanLynnPhyoe-9846 avatar image
0 Votes"
NyanLynnPhyoe-9846 asked AnuragSharma-MSFT commented

ExecuteReader; Commandtext property has not been initialized.Can anyone help me?Plaease.Here is my code.

using System.Windows.Forms;
using ESportCenter.DBA;

namespace ESportCenter.MasterData
{
public partial class frm_regi : Form
{
public frm_regi()
{
InitializeComponent();
}

     clsRegi obj_clsRegi = new clsRegi();
     clsMainDB obj_clsMainDB = new clsMainDB();

     DataTable DT = new DataTable();
     public bool _IsEdit = false;
     public int _PlayerID = 0;
     string SPString = "";
        

     private void frm_regi_Load(object sender, EventArgs e)
     {
         string Day = string.Format("{0:D2}", DateTime.Now.Day);
         string Month = string.Format("{0:D2}", DateTime.Now.Month);
         string Year = string.Format("{0:D2}", DateTime.Now.Year);
         lblStartDate.Text = Month + "/" + Day + "/" + Year;
         txtMemberFees.Text = "0";
         txtPlayerName.Focus();
     }

     private void btnClose_Click(object sender, EventArgs e)
     {
         this.Close();
     }

     private void btnSave_Click(object sender, EventArgs e)
     {
         int OK;
         if (txtPlayerName.Text.Trim().ToString() == string.Empty)
         {
             MessageBox.Show("Please Type PlayerName");
             txtPlayerName.Focus();
         }
         else if (txtPassword.Text.Trim().ToString() == string.Empty)
         {
             MessageBox.Show("Please Type Password");
             txtPassword.Focus();
         }
         else if (txtMemberFees.Text.Trim().ToString() == string.Empty)
         {
             MessageBox.Show("You need money to play");
             txtMemberFees.Focus();
         }
         else if (int.TryParse(txtMemberFees.Text, out OK) == false)
         {
             MessageBox.Show("Cash Should Be Number");
             txtMemberFees.Focus();
         }
         else if (Convert.ToInt32(txtMemberFees.Text) < 3000 || Convert.ToInt32(txtMemberFees.Text) > 10000000)
         {
             MessageBox.Show("Cash Amount Should be between 3000 and 10 Laks ");
             txtMemberFees.Focus();
             txtMemberFees.SelectAll();
         }
         else
         {
             SPString = string.Format("SP_Select_Regi N'{0}',N'{1}',N'{2}'", txtPlayerName.Text.Trim().ToString(), "0", "0");

         }
         DT = obj_clsMainDB.SelectData(SPString);
         if (DT.Rows.Count > 0 && _PlayerID != Convert.ToInt32(DT.Rows[0]["PlayerID"]))
         {
             MessageBox.Show("This Player Is Already Exit");
             txtPlayerName.Focus();
             txtPlayerName.SelectAll();
         }
         else
         {
             obj_clsRegi.PLAYERID = _PlayerID;
             obj_clsRegi.PLAYERNAME = txtPlayerName.Text;
             obj_clsRegi.PASSWORD = txtPassword.Text;
             obj_clsRegi.MEMBERFEES = Convert.ToInt32(txtMemberFees.Text);
             obj_clsRegi.STARTDATE = lblStartDate.Text;
             if (_IsEdit)
             {
                 obj_clsRegi.ACTION = 1;
                 obj_clsRegi.SaveData();
                 MessageBox.Show("Successfully Edit", "Successfully", MessageBoxButtons.OK);
                 this.Close();
             }
             else
             {
                 obj_clsRegi.ACTION = 0;
                 obj_clsRegi.SaveData();
                 MessageBox.Show("Successfully Save", "Successfully", MessageBoxButtons.OK);
                 this.Close();
             }
                
         }
     }
 }

}

sql-server-generalazure-sql-database
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @NyanLynnPhyoe-9846, please let us know if you need any other details on the same.

0 Votes 0 ·
Yufeishao-msft avatar image
0 Votes"
Yufeishao-msft answered

Hi @

from this case
The adapter needs to pass the command text to the command object, you lack the SelectCommand in your adapter probably.

You should set the CommandText property of the command object with your SELECT statement or stored procedure name, you cannot execute an empty command.




If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JanWieldraaijer-1495 avatar image
0 Votes"
JanWieldraaijer-1495 answered

As this is not about the Small Basic language, please remove the "small-basic" tag.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.