|
Hi Gerry,
Gerry Schmitz wrote: A "Hardware Id" (or "instance" id) is not same as a Serial Number. Some humble comments:
1.) Actually that is not entirely correct. The hardware ID is handled by the driver IRP_MN_QUERY_ID[^] request handler and might contain a serial number if Parameters.QueryId.IdType is set to BusQueryDeviceSerialNumber and if the device manufacturer/vendor has supplied it.
2.) A serial number is optional and might not be present. It is completely optional and the device manufacturer is not required to set this information.
3.) You can ask the device if it is capable of giving a serial number by sending a IRP_MN_QUERY_CAPABILITIES[^] request. If the device can supply a serial number then the UniqueID field in the DEVICE_CAPABILITIES structure[^] will be set to TRUE.
4.) The Windows operating system internally is using the device instance ID[^] to uniquely identify devices.
5.) The device instance ID is appended to the tail end of the hardware ID you mentined.
Best Wishes,
-David Delaune
P.S.
If the author of the post wants to write code that would only work with USB printers then he might be able to get something from the USB device descriptor[^]. The USB_DEVICE_DESCRIPTOR structure[^] which contains the same unique identifier. I believe it is also optional and the manufacturer is not required to set this information.
Best Wishes,
-David Delaune
|
|
|
|
|
i have string in Arabic language but it's appear like that
Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ
Basically I need to convert My source string to Arabic and I do it using following code:
i try
string responseXML = Encoding.UTF8.GetString(Encoding.Default.GetBytes(responseXML));
result
Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ
but the right result is
string"د ج ح خ ه ع غ ف ق ث ص ض ط م ن ت ا أ ل لأ ب ي س ش ظ ز و ة ى لا ر ؤ ء ئ ذ"
What I'm doing wrong here?
|
|
|
|
|
You're probably using the wrong encoding.
What encoding does the HTTP response declare?
Content-Encoding - HTTP | MDN[^]
What encoding does the XML document declare (if any)?
XML Declaration - Wikipedia[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i get data from QuickBooks like this
*أاإ ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ
it retrain
the encoding of the xml response declare is ISO-8859-1 (ISO Latin 1)
like this
Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ
i didn't find away to convert it to Arabic direct so i convert it to html encode
like this
Ï Ì Í Î å Ú Û Ý Þ Ë Õ Ö Ø ã ä Ê Ç Ã á áÃ
now i want to convert html encode to Arabic i don't know how can help me thanks
|
|
|
|
|
If the data is encoded using ISO-8859-1, then you can't use UTF8 to decode it.
You need to specify the correct encoding:
Encoding iso = Encoding.GetEncoding("ISO-8859-1");
The question remains, since you already have a string, why are you decoding it to bytes simply to encode it back to a string?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Just print / display responseXML before tinkering with it. Your "result" is single byte characters where the "right result" (and input apparently) happens to be "double-byte" characters.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi,
I tried this code:
<pre lang="C#"> if (DGVName.Rows.Count >= 1)
{
foreach (DataGridViewRow row in DGVName.Rows)
{
row.HeaderCell.Value = (row.Index + 1).ToString();
}
}
But it gives the following runtime error:
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
|
|
|
|
|
None of the code you show uses an index: those are referenced via square brackets.
So that is the wrong code, and you need to use the debugger to find out exactly where in your code the exception is happening.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
And I tried your code in my DGV and it works without problem:
private void FrmMain_Shown(object sender, EventArgs epp)
{
string strConnect = SMDBSupport.SMInstanceStorage.GetInstanceConnectionString("Testing");
using (SqlConnection con = new SqlConnection(strConnect))
{
try
{
con.Open();
using (SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM myTable", con))
{
DataTable dt = new DataTable();
da.Fill(dt);
myDataGridView.DataSource = dt;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
}
private void MyButton_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in myDataGridView.Rows)
{
row.HeaderCell.Value = (row.Index + 1).ToString();
}
}
You need to use the debugger to find out exactly which line of code is throwing the exception - because I don't think it's in the code you think it is!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
This part
row.HeaderCell.Value = (row.Index + 1).ToString(); throws an exception.
I use generalized form in my code so I can use it as a dll file in every project.
|
|
|
|
|
Strange.
It definitely doesn't for me, so it's got to be something to do with your data and / or the DGV itself.
I'd start by breaking it down: put each "dot point" in a separate variable and see which "bit" gives a problem:
int i = row.Index;
i++;
string s = i.Tostring();
var hc = row.HeaderCell;
hc.Value = s; I'm guessing it's something to do with the HeaderCell reference, but it's worth using the debugger to see how many times it goes round that loop before it fails as well ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I checked it. The error occurs in the first loop. Of course, I'm using advanced DataGridView (because of its filter capability). Maybe, I should use native DGV instead.
|
|
|
|
|
That would explain the difference between your code and mine ...
You can filter standard DGVs using a binding source - didn't we tell you that a week ago or so?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm going to change them with standard DGV.
|
|
|
|
|
There was an update to advanced DataGridView. I updated it and the issue solved. The filter function also has very rapid response like Excel.
|
|
|
|
|
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
i'll try to read a cwe xml file. The problem is i have not good solution read it in a good way out
That is a xml file
CWE - Downloads[]
I'll find for example ID "1004" and will read all Items behind.
When i will read value from <background_detail> i find not a way to read this out
XElement xelement = XElement.Load(@".\cwec_v4.4.xml");
var value = from cwe in xelement.Elements().Elements()
where (string)cwe.Attribute("ID") == "1004"
select cwe;
foreach (XElement xEle in value)
{
Console.WriteLine(xEle.Value);
}
var result = xelement.Elements().Elements()
.Where(x => x.Attribute("ID").Value == "1004")
.Elements().Where(x => x.Name == "Background_Details")
.Elements().Where(x => x.Name == "Background_Detail")
.Select(x => x.Value);
Have somebody experience and can help me
modified 8-Jun-21 16:20pm.
|
|
|
|
|
|
The XML document has a default namespace. You need to use that to select elements by name:
var document = XDocument.Load(@".\cwec_v4.4.xml");
var ns = document.Root.Name.Namespace;
int idToFind = 1004;
string detail = doc.Descendants(ns + "Weakness")
.Where(el => (int)el.Attribute("ID") == idToFind)
.Elements(ns + "Background_Details")
.Elements(ns + "Background_Detail")
.Select(el => el.Value)
.FirstOrDefault(); If you want to read multiple values from a single weakness, you'll want to cache the Weakness element:
XElement weakness = document.Descendants(ns + "Weakness")
.FirstOrDefault(el => (int)el.Attribute("ID") == idToFind);
if (weakness != null)
{
string description = (string)weakness.Elements(ns + "Description");
string detail = (string)weakness.Element(ns + "Background_Details").Element(ns + "Background_Detail");
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks a lot, it works wonderfully 
|
|
|
|
|
Hi,
I want to make a managerial app using Xamarin. Is there any free SQL Server on the cloud which I can use in Visual Studio during app development (and as a database source for my app)?
I just only need to have a small amount of storage. My clients will be less than 100.
|
|
|
|
|
There are some - normally associated with free websites - but ... would I use one? Not on your Nellie!
They are free for a reason: very limited storage, very poor or non-existent / expensive tech support, availability and speed can be very low. You really do get what you pay for!
"100 clients" doesn't necessarily mean "low storage volume", it depends on the number of clients and the space each will use. Add to that, that space is not the same as bandwidth / processing time: responses need to be timely as well as small!
And these apply to the website and the DB - so unless you really don't care for security, uptime, or space, I'd pay for it. There are good one available cheap, but use Google to find one i your country if possible - it makes support much easier and (hopefully) quicker.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Azure SQL Service has a trial period for use. Is it possible to put an SQLite database file in the cloud and use the cloud IP address for reading/writing database on clients' devices?
|
|
|
|
|
That is a spectacularly bad idea, and most installations of SQL Server will not allow it - to do that you have to expose the whole DB server to the internet along with all the DBs it handles, with all the security problems that opens up!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|