Click here to Skip to main content
15,917,618 members
Home / Discussions / C#
   

C#

 
Question(Exit) Not to continue the execution Pin
-spy-20-Jul-07 3:09
-spy-20-Jul-07 3:09 
AnswerRe: (Exit) Not to continue the execution Pin
Pete O'Hanlon20-Jul-07 3:15
mvePete O'Hanlon20-Jul-07 3:15 
AnswerRe: (Exit) Not to continue the execution Pin
Waleed Eissa29-Aug-07 10:15
Waleed Eissa29-Aug-07 10:15 
Questionsubstituting variables [modified] Pin
KPThor20-Jul-07 2:49
KPThor20-Jul-07 2:49 
AnswerRe: substituting variables Pin
Colin Angus Mackay20-Jul-07 2:53
Colin Angus Mackay20-Jul-07 2:53 
GeneralRe: substituting variables Pin
KPThor20-Jul-07 3:27
KPThor20-Jul-07 3:27 
GeneralRe: substituting variables Pin
Colin Angus Mackay20-Jul-07 4:16
Colin Angus Mackay20-Jul-07 4:16 
QuestionConvert Null db field to string Pin
kallileo20-Jul-07 2:44
kallileo20-Jul-07 2:44 
I use this code to read some records from a access database with contacts exported from Outlook.
I get an error when the content of a field in the db is NULL bc it cannot be converted to string.
How could I correct this and the convert a Null field in a " " string?

Thanks

static void Main()
{
Program instan = new Program();
instan.ReadContacts();
Console.Read();

}
public void ReadContacts()
{
try
{
OleDbDataReader reader = null;
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\AGH\\epafes_outlook_2007.accdb;Persist Security Info=False");
string comStr = "SELECT FirstName, LastName, BusinessPhone FROM Contacts";
OleDbCommand cmd = new OleDbCommand(comStr, conn);
conn.Open();
reader = cmd.ExecuteReader();
int i=1;
while (reader.Read())
{
string FName = (string)reader["FirstName"];
string LName = (string)reader["LastName"];
string BPhone = (string)reader["BusinessPhone"];

Console.Write("{0,-4}", i);
Console.Write("{0,-13}", FName);
Console.Write("{0,-13}", LName);
Console.Write("{0}", BPhone);
Console.WriteLine();
i++;

}
Console.WriteLine("\nFinish");
conn.Close();
reader.Close();
}
catch (Exception e)
{
Console.Write(e);
}

}
AnswerRe: Convert Null db field to string Pin
Colin Angus Mackay20-Jul-07 2:50
Colin Angus Mackay20-Jul-07 2:50 
AnswerRe: Convert Null db field to string Pin
Le centriste20-Jul-07 2:54
Le centriste20-Jul-07 2:54 
GeneralRe: Convert Null db field to string Pin
Colin Angus Mackay20-Jul-07 2:56
Colin Angus Mackay20-Jul-07 2:56 
GeneralRe: Convert Null db field to string Pin
Le centriste20-Jul-07 2:58
Le centriste20-Jul-07 2:58 
AnswerRe: Convert Null db field to string [modified] Pin
kallileo20-Jul-07 3:02
kallileo20-Jul-07 3:02 
GeneralRe: Convert Null db field to string Pin
Colin Angus Mackay20-Jul-07 3:16
Colin Angus Mackay20-Jul-07 3:16 
GeneralRe: Convert Null db field to string Pin
Le centriste20-Jul-07 3:56
Le centriste20-Jul-07 3:56 
GeneralRe: Convert Null db field to string Pin
m@u20-Jul-07 3:30
m@u20-Jul-07 3:30 
GeneralRe: Convert Null db field to string Pin
kallileo20-Jul-07 3:37
kallileo20-Jul-07 3:37 
QuestionLabel with control Characters Pin
imnotso#20-Jul-07 0:35
imnotso#20-Jul-07 0:35 
AnswerRe: Label with control Characters Pin
Nisha S.20-Jul-07 0:55
Nisha S.20-Jul-07 0:55 
GeneralRe: Label with control Characters Pin
imnotso#20-Jul-07 1:27
imnotso#20-Jul-07 1:27 
Questionbackground Worker Class Pin
Software_Specialist20-Jul-07 0:04
Software_Specialist20-Jul-07 0:04 
AnswerRe: background Worker Class Pin
Bijesh20-Jul-07 0:22
Bijesh20-Jul-07 0:22 
AnswerRe: background Worker Class Pin
Bekjong20-Jul-07 1:20
Bekjong20-Jul-07 1:20 
Questiondatagridview row validating Pin
JoZ CaVaLLo20-Jul-07 0:03
JoZ CaVaLLo20-Jul-07 0:03 
AnswerRe: datagridview row validating Pin
led mike20-Jul-07 7:07
led mike20-Jul-07 7:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.