
quwiltw
Leaders
-
Posts
493 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by quwiltw
-
Are you checking the IsPostBack property when the user submits to tell if this is the first load (populate dropdown) or a postback(grab the selection)? Lookup IsPostBack and see if that helps.
-
Ways to create a new Table in a DB?
quwiltw
replied to Disasterpiece's topic in Database / XML / Reporting
The number of tables wasn't exactly what I was taking issue with -- it was the whole idea of dynamically creating a new table for each user, be it one or one thousand. -
Ways to create a new Table in a DB?
quwiltw
replied to Disasterpiece's topic in Database / XML / Reporting
I must say I think this is a *bad* idea. There are *very* few scenerios (and I can't think of one right now) where the underlying data model should change dynamically. A very poor design in my humble (well kinda) opinion. Maybe we could help you come up with a better design instead? In your case, maybe you could just add a foreign key (userid) to the transactions table. -
Making a type-ssafe collection class bindable..?
quwiltw
replied to Merrion
's topic in Windows Forms
Implement the Add Sub, Create Method, and Item Property with you're datatype in mind. So, for the Item property, you'll do something like this: Default Property Item(ByVal key As String) As MySpecificDataType Get Return CType(Dictionary.Item(key), MySpecificDataType) End Get Set(ByVal Value as MySpecificDataType) Dictionary.Item(key) = Value End Set End Property -
I think this sample will. It's well commented and easily understood. http://www.microsoft.com/downloads/details.aspx?FamilyId=4B3215C0-62E7-4B84-9944-7582B8CD0125&displaylang=en
-
I must say I have no clue about C++ in .NET but have you used the __try_cast described in this article? Maybe since it's managed code it can't simply be casted the same? http://msdn.microsoft.com/msdnmag/issues/01/07/vsnet/default.aspx Then maybe you could at least catch the exception and see what it's complaining about.
-
Thanks for putting it in context Thinker, I was having a really hard time figuring out why in the world it would be censored:)
-
Sorry, I didn't have it, I was asking if it was a bad idea or not;) Here's what I've got so far though. It appears to work in the little (rather ugly) test methods. The Datatable stuff is first, then there is a class that provides the test method for it. File: DataTablePlus.vb ' Class: DataTablePlus ' Purpose: ' Extends the DataTable to let it manage associated Views. Public Class DataTablePlus Inherits DataTable Private m_objViews As New ViewCollection() Public Property Views() As ViewCollection Get Return m_objViews End Get Set(ByVal Value As ViewCollection) m_objViews = Value End Set End Property End Class ' Class: ViewCollection ' Purpose: ' A typed collection that contains a set of DataViewPlus objects. Public Class ViewCollection Inherits CollectionBase Private m_hshViewNames As New Hashtable() Default Public Property Item(ByVal Name As String) As DataViewPlus Get Return CType(List.Item(DirectCast(m_hshViewNames.Item(Name), Integer)), DataViewPlus) End Get Set(ByVal Value As DataViewPlus) List.Item(DirectCast(m_hshViewNames.Item(Name), Integer)) = Value End Set End Property Default Public Property Item(ByVal Index As Integer) As DataViewPlus Get Return CType(List.Item(Index), DataViewPlus) End Get Set(ByVal Value As DataViewPlus) List.Item(Index) = Value End Set End Property Public Function Add(ByVal Item As DataViewPlus) As Integer Dim i As Integer = List.Add(Item) m_hshViewNames.Add(Item.Name, i) Return i End Function Protected Overrides Sub OnRemove(ByVal index As Integer, ByVal value As Object) Dim en As IDictionaryEnumerator Dim sKey As String en = m_hshViewNames.GetEnumerator() While en.MoveNext If CType(en.Value, Integer) = index Then sKey = DirectCast(en.Key, String) End If End While m_hshViewNames.Remove(sKey) End Sub End Class ' Class: DataViewPlus ' Purpose: ' Adds a Name Property to the DataView. Public Class DataViewPlus Inherits DataView Private m_strName As String Public Property Name() As String Get Return m_strName End Get Set(ByVal Value As String) m_strName = Value End Set End Property End Class DataTest.vb Imports System.Text Public Class DataTest Public Sub TestView() Dim ds As New DataSet() Dim dt As New DataTablePlus() ds.Tables.Add(dt) dt.Columns.Add(New DataColumn("FirstName")) dt.Columns.Add(New DataColumn("LastName")) Dim col As ArrayList col = GetPeople() Dim i As Integer For i = 0 To col.Count - 1 Dim dr As DataRow dr = dt.NewRow() dr.Item("FirstName") = DirectCast(col.Item(i), Person).FirstName dr.Item("LastName") = DirectCast(col.Item(i), Person).LastName dt.Rows.Add(dr) Next Dim vew0 As New DataViewPlus() vew0.Name = "All" vew0.Table = dt vew0.RowFilter = "" dt.Views.Add(vew0) Dim vew1 As New DataViewPlus() vew1.Name = "Georges" vew1.Table = dt vew1.RowFilter = "FirstName='George'" dt.Views.Add(vew1) Dim vew2 As New DataViewPlus() vew2.Name = "Thomases" vew2.Table = dt vew2.RowFilter = "FirstName='Thomas'" dt.Views.Add(vew2) PrintView(dt.Views.Item("All")) PrintView(dt.Views.Item("Georges")) PrintView(dt.Views.Item("Thomases")) End Sub Private Function GetPeople() As ArrayList Dim col As New ArrayList() col.Add(New Person("John", "Adams")) col.Add(New Person("Benjamin", "Franklin")) col.Add(New Person("George", "Washington")) col.Add(New Person("Thomas", "Jefferson")) col.Add(New Person("James", "Madison")) col.Add(New Person("Alexander", "Hamilton")) col.Add(New Person("George", "Mason")) Return col End Function Private Sub PrintView(ByVal vw As DataViewPlus) Dim row As DataRow Dim i, n As Integer Dim sb As New StringBuilder() For i = 0 To vw.Count - 1 For n = 0 To vw.Table.Columns.Count - 1 sb.Append(vw.Table.Columns.Item(n).ColumnName) sb.Append("=") sb.Append(vw.Item(i).Item(n)) sb.Append(" : ") Next sb.Append(vbCrLf) Next MsgBox(sb.ToString()) End Sub Private Class Person Public FirstName As String Public LastName As String Public Sub New(ByVal fname As String, ByVal lname As String) FirstName = fname LastName = lname End Sub End Class End Class Edit: Ooops wasn't removing from the hashtable too.
-
What I was thinking was if you have a DataTable, it should be able to have a collection of dataviews that are associated with it. So that you can do something like DataTable.Views("MyView"), for example. My thinking is that the DataViews are inseparable from the DataTable, in that, they are useless without it so why not just make them a part of the data table. Databinding is exactly what I'm trying to support with the DataViews. It's essentially a "Lookup" table of stuff like Eye Color, Hair Color, States, Countries, well.. you get the point. I'm thinking of bringing them all back in a single data table and just have a DataView for each category. This, because it seems clunky to create a bunch of data tables with the exact same structure.
-
I thought there was a collection of dataviews built into the dataset or datatable, but I don't see one now. Am I overlooking something or was it just wishful thinking on my part? Also, assuming it's just not there, anyone see a reason why I shouldn't just give my inherited datasets a strongly typed collection of dataviews? Is there a reason they should be managed separately?
-
When I give a path like that, I kinda expect you to look the details up for yourself. If you're not already, one of the best things you can do to improve your .NET programming skills is get *really* comfortable navigating the Class Library. Having said that, take a look here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemenvironmentclasstickcounttopic.asp and if you still have questions, let me know. Edit: Glad to see you found it.
-
System.Environment.TickCount
-
You should probably check out the TimeSpan class.
-
Set the Read Only attribute of a file
quwiltw
replied to BigSi's topic in Directory / File IO / Registry
You should probably use the File class's SetAttributes method instead. System.IO.File -
No, but it's likely the most mature ASP.NET based forum you'll get that comes with the source code. Why don't you build in the features you feel are missing and post it in their Code Share forum thus giving back to the community and making it a better product? Otherwise, if you want commercially mature software, do as VolteFace has suggested and pay commercial prices.
-
Have you installed AspNetForums? It's built with "skinning" in mind. Just create a new "skin" for it if you don't like the way it looks. Look in the skins subdirectory of the install directory.
-
Change the data type from Text to Memo.
-
Yes. That's what I have above. Maybe I'm misunderstanding your question?
-
Since you wanted the 'M' 's before the 'V's I did min because M < V . It has nothing to do with when they were added. I guess it was just a quick way around seleting the Top 1 ordered by Rights desc. Get it? Here's a better explanation (archived, but accurate as far as this discussion): http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/accessdev/html/ODC_SQLMinAndMax.asp
-
System.Environment.UserDomainName() returns the network domain that you're currently logged on to just as the documentation says. Not sure why it would return the machine name in your case.
-
Did you even take a second to look at the System.Environment before responding?:-\
-
I'm not sure what the problem is but you can get the username from System.Environment.
-
See if this helps... http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/FilterData.aspx
-
Here ya go. I'm not sure if the CreateInstance makes much sense without everything but you might be able to make sense of it. The first two are essentially the tests that I'm using behind a simple little form, the CreateInstance is snipped from the DataProviderHelper class. Here's the tests: Private Sub GenInstancesCustomInstance(ByVal count As Integer) Dim i As Integer Dim p As DataProviderHelper p = New DataProviderHelper() For i = 0 To count Dim cn As IDbConnection Dim cmd As IDbCommand Dim adp As IDbDataAdapter p.CurrentProvider = "System.Data.OleDb" Dim hsh As New Hashtable() hsh.Add("ConnectionString", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & GetDBPath() & ";") cn = p.CreateInstance("IDbConnection", hsh) cmd = p.CreateInstance("IDbCommand", Nothing) adp = p.CreateInstance("IDbDataAdapter", Nothing) cn = Nothing cmd = Nothing adp = Nothing Next p = Nothing End Sub Private Sub GenInstancesBuiltIn(ByVal count As Integer) Dim i As Integer For i = 0 To count Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & GetDBPath() & ";") Dim cmd As New OleDb.OleDbCommand() Dim adp As New OleDb.OleDbDataAdapter() cn = Nothing cmd = Nothing adp = Nothing Next End Sub and here's the createinstance: Public Shared Function CreateInstance(ByVal interfaceName As String, ByVal args As Hashtable) As Object Dim obj As Object Try obj = Activator.CreateInstance(GetCurrentHash().Item(interfaceName)) Catch ex As Exception Throw New Exception("Interface: " & interfaceName & " is not implemented in " & m_strCurrentService, ex) End Try If Not args Is Nothing Then Dim en As IDictionaryEnumerator en = args.GetEnumerator() While en.MoveNext() Dim t As Type = obj.GetType() Dim pi As PropertyInfo = t.GetProperty(en.Key.ToString()) If Not pi Is Nothing Then pi.SetValue(obj, en.Value, Nothing) Else Throw New Exception(en.Key.ToString() & " is not a property of " & obj.GetType().ToString()) End If End While End If Return obj End Function
-
Is the user an administrator?
quwiltw
replied to Merrion
's topic in Interoperation / Office Integration
The WindowsPrinciple class has an IsInRole method that takes a WindowsBuiltInRole enum type (one of which is Administrator). That should get you what you need. This article takes you through the first part but doesn't include a call to IsInRole which should be self-explanatory. http://samples.gotdotnet.com/quickstart/howto/doc/security/WindowsIdentityCheck.aspx