|
Hi,
I discovered the same stuff a year ago when I started using Vista.
In short:
- in order to get the drive serial number you need low-level access to it, i.e. a CreateFile
- although reading some properties is all you need, Vista will not allow you to do so when not running
as administrator. (Try dropping the GENERIC_WRITE).
IMO there is no way around it, disk serial numbers are no longer available to regular users!
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
We have a VS 2003 solution containing 1 vb project and several c# projects. The problem is when i try to build the vb project either VS exits or stuck at "performing main compilation". Please help
|
|
|
|
|
i want to validate the check box present inside the datagrid...
checked or not...
asp.net using c#
foreach (DataGridItem i in DataGrid1 .Items )
{
CheckBox chk = (CheckBox)i.FindControl ("chkbox");
if (chk.Checked )
{
}
}
// i use this to code to add checkbox in data grid
<asp:templatecolumn headertext="Approve" xmlns:asp="#unknown">
<itemtemplate>
<asp:checkbox id="chkbox" runat="server">
if u not able to understand my question plz ask me i will explain..
it is not working properly..
|
|
|
|
|
|
I'm looking for decent article/tutorial demonstrating how to use XmlTextReader to read XML into a (large) object tree. So far the articles are only showing a simple while (reader.Read()) { bla; } loop.
Anyone ever used XmlTextReader to do some serious parsing? Otherwise I'll just go with the XmlDocument thing, that seems to be a lot easier, but I'm curious if anyone has a nice real world usage pattern for XmlTextReader.
Wout
|
|
|
|
|
wout de zeeuw wrote: demonstrating how to use XmlTextReader to read XML into a (large) object tree
wout de zeeuw wrote: Otherwise I'll just go with the XmlDocument thing
The XmlDocument thing is an object tree so why wouldn't you just use it anyway?
|
|
|
|
|
Well, XmlDocument is the easier choice I agree. But if one were to use XmlTextReader to do it, how would that be done typically. I'm just curious if there's a standard way of handling this. I've experimented a bit with XmlTextReader, and I can get things working, but the end result of how I do it feels a bit kludgy.
Wout
|
|
|
|
|
XMLDocument is using a reader internally. You can use reflector to see how reader is used inside that. I think that will help you to understand the usage.
|
|
|
|
|
Nah, XmlDocument builds something generic, but the idea is to parse into a type safe tree of classes. But thanks for the suggestion anyway.
Wout
|
|
|
|
|
wout de zeeuw wrote: but the idea is to parse into a type safe tree of classes
Um, wouldn't that be Serialization?
|
|
|
|
|
Yeah, sort of, except that I want to deserialize an object graph (i.e. objects are sometimes referenced, rather than owned) using my custom xml format (I need tight control over the xml format). I'm now doing a custom implementation, just to see how it ends up... it's a bit involved (but not terrible), see e.g. typical code snippet below:
public static DbTable Read(DbProjectBuilder projectBuilder, XmlTextReader r) {
DbTable table = new DbTable();
bool isEmptyElement = XmlUtil.ReadStartElement(r, "Table");
while (r.IsStartElement()) {
switch (r.Name) {
case "Name":
table.Name = r.ReadElementString();
break;
case "Notes":
table.Notes = r.ReadElementString();
break;
case "PrimaryKeyType":
table.PrimaryKeyType =
(DbPrimaryKeyType)Enum.Parse(typeof(DbPrimaryKeyType), r.ReadElementString());
break;
case "PrimaryKeyName":
table.PrimaryKeyName =
r.ReadElementString();
break;
case "Columns":
ReadColumns(projectBuilder, table, r);
break;
case "Indexes":
ReadIndexes(projectBuilder, table, r);
break;
default:
r.ReadInnerXml();
break;
}
}
if (!isEmptyElement) {
r.ReadEndElement();
}
return table;
}
private static void ReadIndexes(DbProjectBuilder projectBuilder, DbTable table, XmlTextReader r) {
bool isEmptyElement = XmlUtil.ReadStartElement(r, "Indexes");
while (r.IsStartElement()) {
if (r.Name == "TableIndex") {
DbTableIndex tableIndex = DbTableIndex.Read(projectBuilder, table, r);
table.Indexes.Add(tableIndex);
} else {
r.ReadInnerXml();
}
}
if (!isEmptyElement) {
r.ReadEndElement();
}
}
private static void ReadColumns(DbProjectBuilder projectBuilder, DbTable table, XmlTextReader r) {
bool isEmptyElement = XmlUtil.ReadStartElement(r, "Columns");
while (r.IsStartElement()) {
if (r.Name == "Column") {
DbColumn column = DbColumn.Read(projectBuilder, r);
table.Columns.Add(column);
} else {
r.ReadInnerXml();
}
}
if (!isEmptyElement) {
r.ReadEndElement();
}
}
Wout
|
|
|
|
|
wout de zeeuw wrote: see e.g. typical code snippet below:
Ok, um after seeing your code I guess I should warn you that you appear to be reinventing the wheel only yours is shaped like a square.
|
|
|
|
|
led mike wrote: Ok, um after seeing your code I guess I should warn you that you appear to be reinventing the wheel only yours is shaped like a square.
Hehe, and chromed too! My main purpose is experimenting to get a feel for this XmlTextReader thing...
Wout
|
|
|
|
|
If its your custom xml format then you will have an xsd for it. Use xsd.exe to spit out class definitions tagged up for deserialization.
|
|
|
|
|
Hi Guys,
Is there any way to restrict the files browsable in the FileBrowserDialog to a specific directory or sub directory? I've got two directories i want to browse the files in.
Anything like that exist?
Regards
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Ive got an object that I inherit from DataTable and the overloaded constructor shown below
When I try to deserialize it i get the error
"The constructor to deserialize an object of type 'MyLibrary.CSVImport' was not found.
[Serializable]
public class CSVImport : DataTable
public CSVImport():base()
{
}
Project is target 2.0
I must have something missing that I need to do in order to deserialize the object. Below is the code that does the testing
DataTable dt;
FileStream fs = new FileStream(s3, FileMode.Open);
CSVImport csv = new CSVImport(fs,out err);
csv.SetFirstRowAsHeader();
// test serialization
fs = new FileStream(@"C:\test.bin", FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, dt);
fs.Close();
fs = null;
bf = null;
dt = null;
fs = new FileStream(@"C:\test.bin", FileMode.Open);
bf = new BinaryFormatter();
dt = (DataTable)bf.Deserialize(fs);// Boom! Does not like this..
fs.Close();
|
|
|
|
|
If you inherit from a class which has a non-public deserialization constructor, you will have to implement it. Like:
public class CSVImport : DataTable
public CSVImport():base()
{
}
public CSVImport(SerializationInfo info,
StreamingContext context):base(info, context)
{
}
|
|
|
|
|
Thank you...
So in this case the parent DataTable has a non-public deserialization constructor?
|
|
|
|
|
|
I have a problem with binding data using BindingSource, typed dataset and DataGridView. My problem is: BindingSource, therefore grid, is empty after binding data (bindingSource.Count is 0). I couldn't figure out what I'm doing wrong and I'd be very happy if anyone could help me with this.
My application structure is like this: I have two assemblies, one is Winforms UI and other is database class library.
UI
-DataGridView, datasource as BindingSource
-BindingSource, datasource = DBAssembly.typedDataset, datamember = DBAssembly.typedDataset.myTable
Database DLL
-Sql Server CE database
-Typed Dataset
-DB class for database operations
UI Code
OnLoad
this.db = new DB();
db.BindData();
DB Code
constructor
create typedDataSet object
create typedDataSetTableAdapters.MyTableTableAdapter object
create typedDataSetTableAdapters.TableAdapterManager object
BindData()
this.myTableTableAdapter.Fill(this.typedDataSet.MyTable)
I'd appreciate any help with this
|
|
|
|
|
Hi,
Does anyone know what I should install for having support to Microsoft Access database in Entity Framework in Visual Studio 2008 ?
Currently, I see only SQL Server and SQL Server Compact Edition as available database type when I want to add an "ADO.NET Entity Data Model".
Thanks,
Fred
|
|
|
|
|
Access is not supported by the Entity Framework. You can use just about any other database, except Access. You can find providers for 3rd party databases here[^].
|
|
|
|
|
There's an upgrade-wizard in your Access-database that converts your database to SQL Server. You can then use SQL Server Express (a free download) in combination with VS2k8 and the EF.
HTH,
I are troll
|
|
|
|
|
Thanks, but this feature appears only in Access 2007, not in Access 2003. Thanks for the tips.
But the idea is to use a database in a file, so my program would be easy to install for each user.
What do you think of using SQL Server Compact Edition instead ? It seems to be greater than Access.
|
|
|
|
|
WolveFred2 wrote: this feature appears only in Access 2007, not in Access 2003
The feature is older then Access 2007. Might it be that you haven't installed all wizards during the installation of Office 2003?
WolveFred2 wrote: What do you think of using SQL Server Compact Edition instead ? It seems to be greater than Access.
I'd recommend SQLite
SQL CE is missing some features that you may have grown accustomed to in Access. OTOH, installing a SQL Server instance might be overkill if you're just going to save a bit of data locally.
I are troll
|
|
|
|