|
If you use the XML libraries in C# does it not work for your large file? I've never tried anything with a file that big.
ɹǝʌo ɹoʇıuoɯ ɹnoʎ dılɟ sıɥʇ pɐǝɹ ʇ,uɐɔ noʎ ɟı
|
|
|
|
|
I rad about how the garbage collector work.
From what i rad is that any value type variable can't be application root item - so the value type is can't be collect by the garbage collector ?
If not - how the garbage collector collect value type objects ?
|
|
|
|
|
"I read"...not "I rad"...
Value types are allocated on the stack by default, so they don't need to be managed by the GC. Stack objects are discarded whenever that stack frame ends and is popped, which is a fundamental aspect of any program, regardless of whether there is a GC or not.
|
|
|
|
|
Thanks!
just forgot the "e" ... in the read / rad
|
|
|
|
|
Jon Rista wrote: Value types are allocated on the stack by default,
IMO there is no default, i.e. value types are allocated on the stack when they are local variables, and inside their containing type when they are members of an aggregated type (hence
on the heap when members of a class, and where ever it resides when members of a struct).
In each case, there is no explicit garbage collection involved: in the end they reside either on
the stack (hence no garbage collection at all) or are part of a bigger reference type (and collection occurs at that ref type level).
|
|
|
|
|
Well, sure. I wouldn't consider a field in a class as an isolated thing...its an integral part of the class. I think the gyst of the question was "Why isn't an int allocated on the heap and GCed by default". :P
|
|
|
|
|
I think the gyst of the question was "Why isn't an int allocated on the heap and GCed by default".
Non-static class fields are stored on the heap within the memory areas that are allocated to objects. They go bye-bye if the objects containing them are garbage-collected. I believe static fields are stored on the heap as well, but in regions that generally won't go bye-bye until an application terminates (I think there are ways of explicitly unloading DLL's which would nuke any static fields they hold, but I don't know the details).
As noted before, local variables are stored on the stack, and will go bye-bye when, or soon after, they go out of scope.
Note that class variables hold references to objects; the class variables themselves are value types (which may be stored on the stack or within the space allocated for particular objects), but they will cause the system to maintain objects as standalone allocations.
Thus, if there is a local variable of type "System.Text.Stringbuilder", the local variable will exist on the stack only as long as it is within scope. If the variable is not Nothing, there will be an object of type System.Text.Stringbuilder to which that variable points. When the variable goes out of scope, the four or eight bytes used by the reference itself will go away regardless of whether other references exist to the same StringBuilder.
|
|
|
|
|
Static types and fields are stored in what is called a Loader Heap. Loader heaps are separate from the normal GC heap, and are managed in a different way. They are not garbage collected (since they are static and live for the duration of the app, there is no need), and space for statics is preallocated when the AppDomain is loaded. If a Static member contains a reference to another, non-static object...the object that is referenced is actually stored on the GC heap. Static fields and methods are keept on loader heaps because they are considered part of the type system (wich is the primary purpose for loader heaps...to store type metadata, vtables, etc.) Its actually an interesting distinction between static and instance types.
Given that this thread has diverged from simple answers, perhapse the following link will be helpful to everyone. It explains the CLR, GC, and type system in detail:
http://msdn.microsoft.com/en-us/magazine/cc163791.aspx
|
|
|
|
|
I want to link a application to another website via relative path and it's giving me hell, any help?
Ferron
|
|
|
|
|
ferronrsmith wrote: it's giving me hell
Because you can't. Relative paths work within the application, not outside it.
only two letters away from being an asset
|
|
|
|
|
actually got it fixed, thanks man
Ferron
|
|
|
|
|
Care to share the fix?
ɹǝʌo ɹoʇıuoɯ ɹnoʎ dılɟ sıɥʇ pɐǝɹ ʇ,uɐɔ noʎ ɟı
|
|
|
|
|
I have implemented my own MyDataView so that I can process the raw data before it appears in a data grid.
MyDataView implements IBindingList.
MyDataView has a collection of MyDataRow objects. MyDataRow implements ICustomTypeDescriptor.
MyDataView also has a collection of MyDataColumn objects, which it shares with the MyDataRow objects.
MyDataRow exposes the collection of MyDataColumn through the ICustomTypeDescriptor interface.
When assigning the DataSource property of the grid to an instance of MyDataView, it displays all the columns and rows correctly, as long as there is at least one row of data to display.
However, when the MyDataView has no rows, the grid shows a single column called "Column" instead of the actual columns in the collection. This makes sense to me since the columns are exposed through the row, and there are no rows.
Somehow, I need the grid to see MyDataView's column definitions even if there are no rows in the view.
I tried modifying MyDataView to also implement ICustomTypeDescriptor, but it did not seem to have any effect.
How do I get a grid to see MyDataView's column definitions even if there are no rows in the view?
(I'm using the DevExpress.XtraGrid.GridControl from Developer Express.)
|
|
|
|
|
public string connection = "Provider=SQLOLEDB; Data Source=D:king.txt;Catalog=STU_ATTENDANCE;User ID=sa;Password=sa; Network Library=dbmssocn";
SqlConnection con1 = new SqlConnection(connection);
in my text file king i gave this text "veeserv3" <--(this is my data source name)
is it right...
|
|
|
|
|
Please Don't Cross Post
|
|
|
|
|
I don't know if you can treat an arbitrary text as a database. A CSV-text, no problems. It kinda depends on the format of your textfile. Can you show us a small excerpt (5 lines), including escape-characters?
Anyway, if you want to verify that your connection-string works and can connect to the datastore, invoke the function described below;
internal bool TryConnectToSqlInstance(string connectionString)
{
using (SqlConnection con = new SqlConnection(connectionString))
try
{
con.Open();
}
catch (SqlException ex)
{
MessageBox.Show(String.Format("{0}\n\nConnection string: '{1}'", Message, connectionString}
Application.ProductName,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
finally
{
while (con.State == ConnectionState.Connecting)
Application.DoEvents();
if (con.State == ConnectionState.Open)
MessageBox.Show("Connection Succeeded!",
Application.ProductName,
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
You might also be interested in this[^] link, where you can find various connectionstrings for almost every database.
I are troll
|
|
|
|
|
No, you cannot refer to the contents of the text file as the data source. Use config file or read the text from the textfile, for example using File.ReadAllLines[^] amd then place the contents to your connection string.
Something like:
string[] datasource = File.ReadAllLines("D:\\king.txt");
string connection = "Provider=SQLOLEDB; Data Source="
+ datasource[0]
+ ";Catalog=STU_ATTENDANCE;User ID=sa;Password=sa; Network Library=dbmssocn";
modified on Thursday, January 22, 2009 12:15 PM
|
|
|
|
|
nice gentle man u got my problem...
when i include those lines i get this error....
"File does Not exist in the current context"
|
|
|
|
|
File class is under System.IO namespace, so you can refer to it like System.IO.File.ReadAllLines(... or add using System.IO directive to your file.
|
|
|
|
|
i got this error
Could not find file 'D:\king.txt'.
but i have word file in my d:
|
|
|
|
|
As the message says, the file cannot be opened. Re-chek the path and the name and if another application is having that file open, close the other application first.
|
|
|
|
|
the file did not open any where in my project...
i gave like this...
string[] datasource = File.ReadAllLines("D:\\king.txt");
Could not find file 'D:\king.txt'.
if i give like this....
string[] datasource = File.ReadAllLines("D:\king.txt");
Error 1 Unrecognized escape sequence //occurs
i gave like this...
string[] datasource = File.ReadAllLines("D:king.txt");
Could not find file 'D:\king.txt'.
|
|
|
|
|
The problem isn't in your code, but the code cannot open the file from the operating system. Check (for example using windows explorer) that:
- the file is on drive D and in the root directory
- the file is named king.txt
- you have privileges to open the file
- the file isn't open in any program, for example in Microsoft Word etc.
|
|
|
|
|
file read successfully but..
reading in this manner ::ࡱ\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>\0\0\t\0\0\0ࡱ\0\0\0\0\0\0\0\0\0\0\0\0\0
|
|
|
|
|
Are you sure it's a plain text file and not for example in Word format? Open it using notepad. It should answer that question. File-class reads the text as plain text. If the file contains some other format, File class is unable to "translate" it to text.
|
|
|
|