rwheeler23
asked on
Text field from SQL has no value inside code C#
I need to make a decision on this field: this.txtJOBNMBRFROM - this is text box on my form
This field gets its value from a SQL statement. When the screen appears all the values are there. My if statement does not work because the string is blank inside the code. What am I missing?
DataCommand.CommandText = "select top 1 JOBNUMBER,CASE WHEN XFRTOJOB = '' THEN 'NO TRANSFER' ELSE XFRTOJOB END AS XFRTOJOB from job_linker where transnmbr='" + VoucherNumber + "' and len(rtrim(jobnumber))>0";
DataDataAdapter = new System.Data.SqlClient.SqlD ataAdapter ();
DataDataAdapter.SelectComm and = DataCommand;
DataDataAdapter.TableMappi ngs.Add("T able", "JOBNUMBER");
DataDataAdapter.Fill(DataD ataSet);
if (DataDataSet == null || (DataDataSet.Tables.Count == 0) || (DataDataSet.Tables[0].Row s.Count == 0))
{
MessageBox.Show("No job found for this payment in Job Linker. Please return to Inquiry->Purchasing->Trans action By Vendor and enter a job on this payment.");
/* Dispose of the connection */
GPConnObj = null;
/* Shutdown the connection */
resp = GPConnection.Shutdown();
DataConnection.Close();
this.Hide();
this.Dispose();
}
this.txtJOBNMBRORIG.DataBi ndings.Add ("Text", DataDataSet.Tables["JOBNUM BER"], "JOBNUMBER").ToString();
this.txtJOBNMBRORIG.TextAl ign = System.Windows.Forms.Horiz ontalAlign ment.Left;
this.txtJOBNMBRFROM.DataBi ndings.Add ("Text", DataDataSet.Tables["JOBNUM BER"], "XFRTOJOB").ToString();
this.txtJOBNMBRFROM.TextAl ign = System.Windows.Forms.Horiz ontalAlign ment.Left;
mystring = this.txtJOBNMBRFROM.Text.T oString();
MessageBox.Show(mystring + " The length is " + mystring.Length);
-------------------Here is the IF statement -------------------------- ---------- ---------- ---------- ---
if (this.txtJOBNMBRFROM.Text == "NO TRANSFER")
{
this.txtJOBNMBRTO.DataBind ings.Add(" Text", DataDataSet.Tables["JOBNUM BER"], "JOBNUMBER").ToString();
}
else
{
this.txtJOBNMBRTO.DataBind ings.Add(" Text", DataDataSet.Tables["JOBNUM BER"], "XFRTOJOB").ToString();
}
This field gets its value from a SQL statement. When the screen appears all the values are there. My if statement does not work because the string is blank inside the code. What am I missing?
DataCommand.CommandText = "select top 1 JOBNUMBER,CASE WHEN XFRTOJOB = '' THEN 'NO TRANSFER' ELSE XFRTOJOB END AS XFRTOJOB from job_linker where transnmbr='" + VoucherNumber + "' and len(rtrim(jobnumber))>0";
DataDataAdapter = new System.Data.SqlClient.SqlD
DataDataAdapter.SelectComm
DataDataAdapter.TableMappi
DataDataAdapter.Fill(DataD
if (DataDataSet == null || (DataDataSet.Tables.Count == 0) || (DataDataSet.Tables[0].Row
{
MessageBox.Show("No job found for this payment in Job Linker. Please return to Inquiry->Purchasing->Trans
/* Dispose of the connection */
GPConnObj = null;
/* Shutdown the connection */
resp = GPConnection.Shutdown();
DataConnection.Close();
this.Hide();
this.Dispose();
}
this.txtJOBNMBRORIG.DataBi
this.txtJOBNMBRORIG.TextAl
this.txtJOBNMBRFROM.DataBi
this.txtJOBNMBRFROM.TextAl
mystring = this.txtJOBNMBRFROM.Text.T
MessageBox.Show(mystring + " The length is " + mystring.Length);
-------------------Here is the IF statement --------------------------
if (this.txtJOBNMBRFROM.Text == "NO TRANSFER")
{
this.txtJOBNMBRTO.DataBind
}
else
{
this.txtJOBNMBRTO.DataBind
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER