Click here to Skip to main content
15,915,172 members
Home / Discussions / C#
   

C#

 
AnswerRe: Dynamic instantiation of MDI child windows Pin
Stefan Troschuetz23-May-06 6:05
Stefan Troschuetz23-May-06 6:05 
QuestionUpdate command..plz urgnt Pin
r_e_h_a_n23-May-06 5:07
r_e_h_a_n23-May-06 5:07 
AnswerRe: Update command..plz urgnt Pin
da vinci coder23-May-06 8:59
da vinci coder23-May-06 8:59 
GeneralRe: Update command..plz urgnt Pin
r_e_h_a_n24-May-06 6:39
r_e_h_a_n24-May-06 6:39 
AnswerRe: Update command..plz urgnt Pin
StevenS_Dev23-May-06 11:25
StevenS_Dev23-May-06 11:25 
GeneralRe: Update command..plz urgnt Pin
r_e_h_a_n24-May-06 6:38
r_e_h_a_n24-May-06 6:38 
AnswerRe: Update command..plz urgnt Pin
StevenS_Dev24-May-06 13:23
StevenS_Dev24-May-06 13:23 
QuestionHELP - Embedded null in a string from FoxPro using ADO.Net Pin
Martiankeeper23-May-06 4:48
Martiankeeper23-May-06 4:48 
Hi.

I am extracting fields from a FoxPro database.
For reasons that I won't go into, one of the character fields contains an array of 4 characters.

The first character is almost always a Unicode-null.

Now .. When I read this field using a System.Data.DataRow .. it thinks the field is a blank string (String.Empty).

This is because, a string variable is basically a character array, terminated by a unicode-null value.
My character array is therefore immediately terminated (as the first character is a null character).

How on earth do I extract these field values?
I can do this in VBA (in Access) using the same connection string. It returns a string of the individual unicode characters ... but in .Net (both C#.Net and VB.Net) I get returned a blank string.

HELP ?



My Code<br />
// Initialize database connection.<br />
OleDbConnection _connection = new OleDbConnection( @"Provider=VFPOLEDB.1;Data Source=C:\DataFolder\;");<br />
<br />
// SQL select statement<br />
string strSelect = "SELECT * FROM table1";<br />
<br />
// Create data adapter, command builder and dataset<br />
OleDbDataAdapter _dataAdapter = new OleDbDataAdapter(strSelect, _connection);<br />
OleDbCommandBuilder _commandBuilder = new OleDbCommandBuilder(_dataAdapter);<br />
DataSet _dataset = new DataSet();<br />
<br />
// Fill the dataset with the data<br />
_dataAdapter.FillSchema(_dataset, SchemaType.Source);<br />
_dataAdapter.Fill(_dataset);<br />
<br />
// Loop through each of the rows in the dataset<br />
foreach(DataRow dr in _dataset.Tables[0].Rows)<br />
{<br />
    // object contains a blank string ...<br />
    // no options to convert to a character array<br />
   // cannot extract ANY other character values.<br />
    object thisField = dr["myField"];<br />
}<br />


<br />
// Example of what I mean with strings and embedded nulls<br />
<br />
// create a string<br />
string myStr = "Hello World";<br />
<br />
// create a unicode-null character (ASCII = 0)<br />
char myChar = Convert.ToChar(0);<br />
<br />
// replace the characters<br />
myStr = myStr.Replace("l", myChar);<br />
<br />
Console.Writeline ( myStr );<br />
<br />
// writes "He"<br />
// as the string is terminated at the first "null" character ..<br />


Any help would be appreciated.

Thankyou

MKeeper

"imagine how stupid the average person is ...
now imagine that half the planet is more stupid than that!"
QuestionAdding a language to the Vis05 IDE [modified] Pin
Ista23-May-06 4:43
Ista23-May-06 4:43 
QuestionConfigurationManager Pin
Chris Losinger23-May-06 4:37
professionalChris Losinger23-May-06 4:37 
AnswerRe: ConfigurationManager Pin
Ista23-May-06 4:40
Ista23-May-06 4:40 
GeneralRe: ConfigurationManager Pin
Chris Losinger23-May-06 4:55
professionalChris Losinger23-May-06 4:55 
GeneralRe: ConfigurationManager Pin
Ista23-May-06 4:56
Ista23-May-06 4:56 
GeneralRe: ConfigurationManager Pin
Chris Losinger23-May-06 5:28
professionalChris Losinger23-May-06 5:28 
AnswerNevermind... Pin
Chris Losinger23-May-06 5:52
professionalChris Losinger23-May-06 5:52 
AnswerRe: ConfigurationManager Pin
Dustin Metzgar23-May-06 5:56
Dustin Metzgar23-May-06 5:56 
GeneralRe: ConfigurationManager Pin
Chris Losinger23-May-06 6:27
professionalChris Losinger23-May-06 6:27 
GeneralRe: ConfigurationManager Pin
S. Senthil Kumar23-May-06 22:40
S. Senthil Kumar23-May-06 22:40 
QuestionNeed to Embed Build Date and Time [modified] Pin
Jethro6323-May-06 3:50
Jethro6323-May-06 3:50 
AnswerRe: Need to Embed Build Date and Time [modified] Pin
stancrm23-May-06 4:05
stancrm23-May-06 4:05 
AnswerRe: Need to Embed Build Date and Time [modified] Pin
drc_no123-May-06 4:06
drc_no123-May-06 4:06 
GeneralRe: Need to Embed Build Date and Time [modified] Pin
Jethro6323-May-06 4:18
Jethro6323-May-06 4:18 
AnswerRe: Need to Embed Build Date and Time [modified] Pin
Josh Smith23-May-06 4:21
Josh Smith23-May-06 4:21 
AnswerRe: Need to Embed Build Date and Time [modified] Pin
Dustin Metzgar23-May-06 4:42
Dustin Metzgar23-May-06 4:42 
AnswerRe: Need to Embed Build Date and Time [modified] Pin
Judah Gabriel Himango23-May-06 10:22
sponsorJudah Gabriel Himango23-May-06 10:22 

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.