|
You're using the old VB6 syntax. What you're doing is wrong on at least a few levels. Not the least of which is that indexers (you For statement) are never Longs, but instead should be Integers. On top of that, you never use the indexer (_irow)!
It should read more like this:
For index As Integer = 0 To dv.Count - 1
DataRowView rowView = dv(index)
If Not IsDBNull(rowView("serial")) Then
' This next line is meaningless because you'll never see the textbox
' update on a per-row basis. You'll only see the changes made by the
' last iteration of the enclosing For/Next loop.
' Also, why are you even bothering to try to convert DbNull to a String??
txtSerial.Text = ...
' You should be moving this database Delete to it's own method.
' You should also be converting it to a parameterized query instead of
' using string concatenation to build the query.
' You also never execute to command, so nothing really happens here.
' The database connection string and connection open statements really
' should not be inside the For/Next loop.
End If
Next
|
|
|
|
|
plz send me any one examples of use of calendar , date api in asp.net
email- alakhn4@gmail.com
|
|
|
|
|
|
1. You haven't described your question/problem well
2. You've chosen the wrong forum, there is a separate forum for ASP.NET
3. Asking for code will only get your post and your profile reported and possibly removed
4. No one is going to write code for you or take the pain to find the code and email it to you
5. The only thing that you can expect to receive from this post is quite a good amount of spam.
|
|
|
|
|
Hi. I am coding a program (important: .NET 2 (3.5), C#) where i get input of GUIDs in various formats. On MSDN is documented, that it is possible to use
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
or zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz
or {zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz}
or (zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz)
or {0xzzzzzzzz, 0xzzzz, 0xzzzz,0xzz,0xzz,0xzz,0xzz,0xzz,0xzz,0xzz,0xzz}} The goal is to produce a (hex)string of length 32 characters (for 16 bytes) regardless of input.
So I programmed and debugged and tested and looked ...
System.Guid test=new System.Guid("{2426186D-B96D-4656-9B65-15C727744643}");
System.Console.WriteLine(BitConverter.ToString(test.ToByteArray()).Replace("-", string.Empty));
What goes wrong? I expect to see "2426186DB96D46569B6515C727744643", but get
"6D1826246DB956469B6515C727744643". Please give advice. TIA Nicki.
|
|
|
|
|
Make sure the result from "ToByteArray()" is what you expect it to be.
Put that operation on a separate line, and place a breakpoint so you can examine the resulting byte array.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
?test.ToString();
"2426186d-b96d-4656-9b65-15c727744643"
byte[] bytes=test.ToByteArray();
{byte[16]}
[0]: 109
[1]: 24
[2]: 38
[3]: 36
[4]: 109
[5]: 185
[6]: 86
[7]: 70
[8]: 155
[9]: 101
[10]: 21
[11]: 199
[12]: 39
[13]: 116
[14]: 70
[15]: 67 ... and the byte order is messed
|
|
|
|
|
So can you use test.ToString()?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Yes,
?test.ToString().Replace("-",string.Empty);
"2426186db96d46569b6515c727744643"
will fit my needs. So this will be the permanent workaround as solution. But the (IMHO) missbehavior with .ToByteArray() will remain. THX anyway, Nicki.
|
|
|
|
|
It' not misbehaving. It's doing exactly what it should be doing. ToByteArray is not setup to return an array of bytes to YOUR liking. It's setup to return an array of bytes that can be used to quickly build another Guid object.
Internally, the GUID value is not stored as an array of bytes, but as individual fields of various types, combining to form a single GUID. These types include Int32, Short and Byte.
What you think is misbehavior is the correct representation of a 32-bit integer and of a Short and of individual bytes.
|
|
|
|
|
|
Why don't you use "test.ToString()"?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Quick Test in Immediate Window:
Guid test=new Guid("{2426186D-B96D-4656-9B65-15C727744643}");
{2426186d-b96d-4656-9b65-15c727744643}
_a: 606476397
_b: -18067
_c: 18006
_d: 155
_e: 101
_f: 21
_g: 199
_h: 39
_i: 116
_j: 70
_k: 67
?test.ToString();
"2426186d-b96d-4656-9b65-15c727744643"
|
|
|
|
|
I want to create a table "Employee" with columns:empname,age and empcode(which takes two letters from employee name and append number to it.,e.g.:-ga1,om2 where ga stands for ganesh,om stands for omkar)
please help me with the following
|
|
|
|
|
It's already in the C# forum; please don't cross-post.
FWIW, sounds like a calculated field to me.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Take the first two characters of one name and concatenate to the other.
|
|
|
|
|
Hello, my 2nd post here, so I'm a bit of a nOOb.
AFAIK the convention for using Radio Buttons is to have 1 selected by default.
Q: Is it reasonable or acceptable to break this convention for the purpose of forcing the user to make a deliberate selection in a customised application?
B/ground: I made the buttons myself using Small Basic and they are for a Pizza order form. One group has 2 sets of buttons, 1 set [small, medium, large], 2nd set [thin, thick]. The user can only continue once selection is made.
Currently I'm thinking why not by considering that a convention is a wise and preferred norm as opposed to a rule which may not allow such discretion. Also I read that some API's allow the use of RB's without having 1 selected by default.
|
|
|
|
|
Sure, I don't see why that wouldn't be acceptable. It is a practice used many places. As an example, on the CodeProject main page, there is a new survey every week and when it is the type that requires a radio button input, none of the options are initially selected.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
Thanks Soren for your helpful reply.
Wow I just realised it is xmas on the other side of the planet. Happy xmas.
Yeah I think conventions are contextual. 'When in CodeProjectLand do as CodeProjectarians do'.
|
|
|
|
|
Jibba Jabba wrote: Yeah I think conventions are contextual. 'When in CodeProjectLand do as CodeProjectarians do'. I wouldn't say that, I see that behavior all the time, referring to the CP survey just seemed like an obvious thing to do.
Jibba Jabba wrote: Wow I just realised it is xmas on the other side of the planet. Happy xmas. Merry Christmas to you too.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
"I wouldn't say that, I see that behavior all the time, referring to the CP survey just seemed like an obvious thing to do."
Thanks, helpful reply. And I agree.
In my solution to the exercise, not only was it obvious, I stated (on the other forum) that the hypothetical pizza shop owner wanted it. Happy user? That's gotta be good.
Appreciate your experience and thoughts.
|
|
|
|
|
I see it both ways many times. It all depends on what your needs are. If you want to force a selection then don't have one selected by default.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Thanks for your replies.
I just found the vote helpful button. Was a bit slow, nOOb issues.
|
|
|
|
|
You're welcome.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|