Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 01-12-2008
Member
 
Join Date: Nov 2008
Posts: 159
Error message when compiling SQL and C# project

Hey recently I have begun with my SQL and C# project. I have a table that have a row called "log" and a table also called as "log". I then try and make it so that when I press a button with the name of the log should get a message box with history. Below you can see the code and error message. Someone who knows. please help me to get it to work?

Code:
private void logToolStripMenuItem_Click (object sender, EventArgs e) 
{ 
string transID; 
datatable_log = new Bluetooth_Sender_v._1._4.data_blue.logDataTable(); 
datatable_log = dataadapter_log.GetDataBy(transID); 
if (datatable_log.Rows.Count == 0) 
{ 
MessageBox.Show ("The Log is empty"); 
} 
else 
{ 
string log_alert; 
foreach (DataRow row in datatable_log.Rows) 
{ 
log_alert = row ["log"]. ToString (); 
} 
MessageBox.Show (log_alert); 
} 
}
Error Message:
Quote:
Error CS0165: Use of unassigned local variable 'transID'
Error CS0165: Use of unassigned local variable 'log_alert'
Reply With Quote
  #2  
Old 01-12-2008
Member
 
Join Date: May 2008
Posts: 945
Re: Error message when compiling SQL and C# project

"use of unassigned local variable" error message clearly indicates that you are using variables that has not been assigned any value. In your case, the compiler is unable to find any values for "transID" and "log_alert" variables.
Reply With Quote
  #3  
Old 01-12-2008
Member
 
Join Date: Nov 2008
Posts: 159
Re: Error message when compiling SQL and C# project

All right thanks but whatever it does not work either. So if someone could help me with this then it would be great.
Reply With Quote
  #4  
Old 01-12-2008
Member
 
Join Date: Feb 2008
Posts: 194
Re: Error message when compiling SQL and C# project

I think the following will work. It is probably also appropriate to add the line breaks after each line of the log that is added to logMsg.

Good luck

Code:
private void logToolStripMenuItem_Click (object sender, EventArgs e) 
{
// Declare variables 
String transId = String.Empty; // Transaction Id that we want to show 
String logMsg = String.Empty; // Message 
datatable_log = new Bluetooth_Sender_v._1._4.data_blue.logDataTable ();

// Retrieve data 
/* 
* This assumes that 'dataadapter_log' is instansiert in class 'logToolStripMenuItem_Click' 
* Are in, and that it has a valid connection string. 
*/ 
datatable_log = dataadapter_log.GetDataBy (transId); 

// Processes and view data 
if (datatable_log.Count == 0) 
{
logMsg = "The log is empty."; 
}
else 
{
foreach (DataRow row in datatable_log.Rows)
{ 
if (row ["log"]! = null) 
logMsg += (String) row ["log"]; 
}
}
MessageBox.Show (logMsg); 
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Error message when compiling SQL and C# project"
Thread Thread Starter Forum Replies Last Post
STDOLE2.TLB error message when opening Project Fatmeer Microsoft Project 14 02-12-2013 11:29 AM
MS Office Project has stopped working error message Frragrant Microsoft Project 14 15-04-2012 02:47 PM
Macro VB project Message error message after closing Microsoft Excel file Eas!war Windows Software 5 13-01-2012 05:20 PM
Error compiling easyapache Who is it Software Development 6 16-06-2010 04:13 AM
I get "Bot Conversation Do While loop error" message in my project KADRI Software Development 4 25-01-2010 10:08 PM


All times are GMT +5.5. The time now is 04:26 AM.