|
And what about second suggestion to use trigger?? Is that safe?
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
Yes, a trigger would be safe (provided of course that you write the trigger correctly).
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: Yes, a trigger would be safe (provided of course that you write the trigger correctly).
I thought about trigger after max . Not sure why?
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
The scope_identity() function doesn't exist in some older versions of SQL, but in any version of SQL that supports it it is the easiest and most robust approach. It is guaranteed to work regardless of the number of clients accessing the database simultaneously. Approaches using max() or other such techniques can fail if, e.g., a client adds a record, then another client adds a record, then the first client queries max(). By contrast, if a client adds a record and later calls scope_identity(), it is guaranteed to return the last record added by that client even if other records have been added by other clients in the interim.
|
|
|
|
|
That depends on what database you are using.
For Access: "select @@identity"
For MS SQL: "select scope_identity()"
For MySQL: "select last_insert_id()"
You have to use this query on the same connection that you used to insert the record. This variable has database session scope, so it's safe even in a multi-user environment. Even if another user has added a record just after you did, you will still get the last id that was created using your database connection.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i m using vb.net2005, and working on a project, i want to restrict the new user to register the software. so what is the code for main board registration or hard drive registration?
asif rafiq
|
|
|
|
|
WMI is what you want to look into, that's how you read all that sort of stuff.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi,
first of all give reference to "System.management" in you application and import it in code window . After that use following code
dim objBaseBoard as ManagementObjectSearcher = New ManagementObjectSearcher("Select * From Win32_BaseBoard")<br />
<br />
For Each objMgmt In objBaseBoard.Get<br />
m_MotherBoardNumber = objMgmt("SerialNumber")<br />
Exit For<br />
Next
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
No manufacturer is required to expose this information at all, let alone do it through WMI.
You MIGHT get a serial number for the motherboard, you might not. Hard Drives are a bit more reliable, but there still isn't 100% exposure of the serial number by every manufacturer.
A more reliable method would be to pick information from a variety of sources and combine it in some way to form a more unique "fingerprint" of the hardware.
|
|
|
|
|
Hello friends,
I am developing a mdi application.
I have a form that takes input from user, and based on user selection , open a form as mdi child. i want the UserSelectionForm to stay on the top of all the other forms including MDI parent and any other mdi child forms until user has made any selection or cancelled the form.
any help?
:- Rashid Ali -:
modified on Tuesday, February 26, 2008 6:11 PM
|
|
|
|
|
I'm not sure I follow which forms are popups and which are embedded in the MDI app. But, to keep a child form open, set it's parent/owner to be the form you want it to always be above, usually the main form of the app.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
When you go to show the form use:
form.ShowDialog();
instead of:
form.Show();
ShowDialog tells .net to open the form as a modal dialog instead of a standard form.
here is the Solution i got from some other forum
:- Rashid Ali -:
|
|
|
|
|
Oh - I didn't tell you that, because you didn't post code, so I couldn't understand that this was the problem. Glad you got it sorted.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
this may seem elementry ......I have two update pannels and i can't seem to position them side by side. Is there any way that the positioning can be made absolute????
many thanks in advance
|
|
|
|
|
If you're using VB.NET you can use Anchor property to set their place.
For one use Top,Left and for second Top,Right
As far as I understand what you're trying to do, it will solve your problem.
|
|
|
|
|
How do i actually set the anchor property??I have had a look on google but no help.
many thanks
|
|
|
|
|
I got an print screen on the following link. Basically you select an object on form (In form Designer View you can do that) and then look into properties window, You should be able to find anchor.
here's the link
www.ppatel.co.uk/anchor.jpg
|
|
|
|
|
I have a DataGridView that has worked great for months and now there is something causing a RowError event. All it says is Value is not valid for the DataGridViewComboBoxCell and I have done work to alleviate one part of the issue which had something to do with the AllCells auto sizing option. The other issue is that instead of showing the value when it is truly in the list it is raising that event and everything is blank.
It is raising the error during the initial row adding logic after binding the data grid and it seems to get itself caught in some kind of DataError loop.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
modified on Tuesday, February 26, 2008 3:16 PM
|
|
|
|
|
Are you sure the data being bound to the grid is correct? I had this happen once and realized later I was passing null values because of a change in the SQL that brought my data back from the database. If it worked before and doesn't now, I'd guess it HAS to be the data that is the trouble. If you are sure that is not the case, perhaps more information could spark something for us, like how is your combobox column set up? Do you set the DataSource, DataPropertyName, DisplayMember, and ValueMember properties in code or at design time? And in what order?
Hope this helps.
|
|
|
|
|
For this grid I add all items to the combobox with no filtering when I first open up the form like this.
For Each sizeRow As DataRow In _SizesToFilter.Rows
CType(uxDataGrid.Columns("uxSizeGrid"), DataGridViewComboBoxColumn).Items.Add(sizeRow("Size").ToString)
Next
Then when I filter I do the following.
If filterCell.Value IsNot Nothing Then
_SizesToFilter= _DataAccess.GetSizesFiltered(filterCell.Value.ToString)
sizeCell.DisplayMember = "Size"
sizeCell.DataSource = _SizesToFilter
Dim sizeRows As DataRow() = _SizesToFilter.Select("Size = '" & filterCell.Value.ToString.Trim & "'")
If sizeRows.Length > 0 Then
sizeCell.Value = sizeRows(0)("Size")
Else
If _SizesToFilter.Rows.Count = 2 Then
sizeCell.Value = _SizesToFilter.Rows(1)("Size").ToString
Else
sizeCell.Value = ""
End If
End If
End If
All of this is working and I checked the database, there are no NULL values and I havent changed the select statements in quite a while. The part that is breaking is after all of the values are added. It seems that the value is technically selected but the combobox does not show anything, it shows my blank option.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Could it be a DataType error? If I'm reading your code correctly, you are adding all sizes into the box as strings, but when you set them:
sizeCell.Value = sizeRows(0)("Size")
are you sure the sizeRows(0)("Size") is a string? Would adding a .ToString and maybe some trim (and ToUpper if these actually contain alpha characters) fix the issue?
I'm guessing you checked this, but just in case you didn't, have you checked that your filter is returning one or two records all the time? You are setting the value to "" if the filtered rows come back with a count of 3 or more...
Other than that, nothing obvious jumps out at me. Sorry. Hopefully someone else can see something I missed.
|
|
|
|
|
The Data Types match but the issue seems to be happening during the initial value set during the data binding process before it ever gets to my code. It seems to be random and doesnt occur with all sets of data so this is very strange.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Why does visual basic not display the namespace at the top of each code file like C# files do?
I am trying to make a namespace span multiple assemblies in VB, but since the namespaces are not visible i cannot simply go in and change them. The only way I have found to do this is to make the root namespace the same for each assembly (from the project properties window), and then make any sub namespaces from there.
Is there an option to see the namespace in a VB code file, or else a different way to share a namespace among assemblies without making all of their root namespaces the same?
Thanks,
Aaron
|
|
|
|
|
Above the class declaration you can simply type Namespace WhateverTheNameShouldBe and then after End Class place End Namespace . You might want to remove the root namespace if you do this unless you want something to show up as WhateverTheNameShouldBe.WhateverTheNameShouldBe.ClassName OR keep the root namespace and only add the different named namespaces if you require further organization.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Thanks for the help, Cleako! You are very wise and kind. One problem, though:
I am using tableAdapters and other microsoft generated objects that will not allow me to edit their code-behind files. Or, if I do, the changes will be overwritten after a change in the designer. Is there any way to "override" the root namespace property when writing an individual class, or else is there a way to place all of my tableAdapters in a "sub namespace" without editing their code, say by placing them in a namespace folder or something?
Thanks,
Aaron
|
|
|
|