|
No it wasn't sufficiently clear to me. Maybe a couple examples would help.
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
|
|
|
|
|
Well, you need to start with something. You already mentioned that you were starting with the current day. From there, Calendar gives you some useful tools to determine important things, like if the current year is a leap year (in which the last day of Feb. is the 29th), etc. Calendar won't do the work for you...it will just simplify the work. There is indeed an algorithm that needs to be written to calculate the series, and that I'll leave up to you. I just thought the Calendar class might help you with some of the odd cases (i.e. leap year), finding the last day of each month dynamically, etc.
|
|
|
|
|
nzmike wrote: at present I'm adding the months to today's date, setting the day to 1
Same as i would do ...
nzmike wrote: then simply looping though testing each day until I find what I want
... not what i would do.
Let's say you find the 1st of the month of interest is a Wed. (Apr.2009) (which most datetime/cal classes will give).
From where you are now, do:
enum {Mon, Tues, Wed, Thurs, Fri, Sat, Sun} Days;
int weekfirst[7] = [6, 7, 1, 2, 3, 4, 5]
int weeklast[7] = [27, 28, 29, 30, 24, 25, 26]
int *week = weekfirst;
int mul = 1;
If parse 'last' then
mul = -1
week = weeklast
int weekdayidx = (index of lowest number in first 5 elements of week)
int occurence = (default = 0, parse 'first' gives 0, 'second' gives 1, ...);
int offset = 7 * occurence * mul;
int day = offset;
switch( type ) {
case Weekday : a bit more fidly, but should be easy from here; break;
case Monday : day += week[Mon]; break;
...
}
e.g.
2nd Thurs = 7*1*1 + 2 = 9th
1st Mon = 7*0*1 + 6 = 6th
last Tues = 7*0*-1 + 28 = 28th
2nd last Sat = 7*1*-1 + 25 = 18th
[EDIT] whoops, sorry about the C syntax, forgot is was in .net forum [/EDIT]
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
How to develop smart Card Application
in C# windows Application.
Please reply soon.
|
|
|
|
|
Connect a smart card reader to a serial port on your computer, use the serialport component in .net to comunicate whit the reader. then do some research on what protocols and formats you need to use, and go from there
|
|
|
|
|
can any suggest me a book to learn...
asp.net using C#
i want learn from the basic...
book with many examples..
book name
author name and edition..
|
|
|
|
|
I'm reading Pro ASP.NET 3.5 in C# 2008 second edition by matthew macdonald and mario szpuszta, published by apress, they have other books that are pretty good also such as Pro C# 2008 and the .NET 3.5 Platform by Andrew Troelsen (Apress 2007)
|
|
|
|
|
|
try
OdbcConnectionObject.BeginTransaction
INSERT INTO TABLE1
INSERT INTO TABLE2
INSERT INTO TABLE3
OdbcConnectionObject.Commit
Catch ex as Exception
OdbcConnectionObject.Rollback
End Try
When INSERT INTO TABLE1 is completed, I stop the program but data in TABLE1 is already inserted. Autocommit mode is turned off in oracle.
Why does it happen?
|
|
|
|
|
It shouldn't happen. Could you use debugger, execute the first insert and check on the database side if your connection is having a transaction. If not, the transaction is committed somewhere by force. Without seeing the actual code it's quite hard to say more. One thing you could also do is check ODBC driver settings.
|
|
|
|
|
All,
I am having a bit of a headache with serialization of a custom class when using remoting. I am sure the problem is when remoting serializes a List<> of any type.
I was following the article by Marcel Heeremans - http://www.codeproject.com/KB/IP/TwoWayRemoting.aspx[^]
I managed to convert the program into a VB.NET service that communicates with a client exe. However, I wanted to create a custom type to enable messaging to a client.
I created my custom class that would be passed to a client via callback. This class is MessagePrompt (see below). I have changed my list type to String for this post as this fails as well as having any list type.
When the object is passed from server to client via callback, it fails. No exceptions are raised. However, from the tracing, I can see the object get successfully serialized at runtime. However, the client does not receive the object in the callback.
If I comment the following line, the the client does receive the object in the callback:
info.AddValue("Actions", _actions, GetType(List(Of String)))
If I manually serialize and deserialize the object then with XmlSerializer and StringWriter/StringReader, then it would appear to work fine in the client application.
Are there any issues as to why this would fail?
My assemblies are not strongly names as this causes the client callback to not work from the off. Therefore nothing is installed in the GAC.
Am I missing something?
Any pointers as to what I need to look at?
I can change the type to an ArrayList which would work but ideally I want to have a typed list.
Cheers for any help,
Paul
Here is my class:
<Serializable()> _
Public Class MessagePrompt
Implements ISerializable
Public _name As String
' this is the problem...
Public _actions As List(Of String)
Public Sub New()
End Sub
Public Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
Try
Trace.WriteLine("MessagePrompt.New: Deserializing")
_actions = CType(info.GetValue("Actions", GetType(List(Of String))), List(Of String))
Trace.WriteLine("MessagePrompt.New: There are " & _actions.Count & " actions")
Catch ex As Exception
Trace.WriteLine("MessagePrompt.New: Exception encountered deserializing.")
Trace.WriteLine(ex.ToString())
End Try
End Sub
Public Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData
Trace.WriteLine("MessagePrompt.GetObjectData: Serializing")
' comment this line and all works fine!!!!!! except that
' the values I need will not come across the wire unless I use
' array list.
info.AddValue("Actions", _actions, GetType(List(Of String)))
End Sub
End Class
modified on Tuesday, February 3, 2009 5:46 AM
|
|
|
|
|
I'm trying to test how my app will behave with a hardened CAS policy. Since I don't want to affect any other applications I tried to create a custom code group underneath users-All_code. I picked application directory as the membership condition, but can't find where to specify what the directory used is.
Since I've never messed with CAS policy before, I assume there's something I'm not getting; but don't know what.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
|
I'll keep that title n mind if we go from Maybe to Will on having to implement some hardening constraints. ATM I'm trying to find out what a few settings do and how much, if any, impact switching from default to locked down will have.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Kindly tell me what is N-hypernet and usage with sample code or refer any link plz..
|
|
|
|
|
kamakshim wrote: Kindly tell me what is N-hypernet and usage with sample code or refer any link plz..
I have no idea. However there is thing called the internet and it contains information services called search engines. You can type stuff into those search engines and they go off and search for things. Neat, huh!
Here is a demonstration of how to use one of those search engines, a popular one, called the "Google". How to search the "Google" for N-hypernet[^]
|
|
|
|
|
Should I click that link? Or will Google's cold hard reality burst my dreams of the sheer awesomeness of what I imagine an N-HYPERNET to be?
Zoooooooom! Oh boy, zap those n-internets through the hypertubes! Whee! I am going to send an internet to my staff next friday, and it got here TODAY!
|
|
|
|
|
I've never heard of N-hypernet. Is it remotely possible that you're thinking of NHibernate?
|
|
|
|
|
ya sorry by mistakely typed, kindly explain about this
|
|
|
|
|
It's an Object Relational Mapper (ORM) - you can find a sample here[^].
|
|
|
|
|
Hi,
I've jest upgraded from VS-2005 to VS-2008.
When I try to run any of my old projects I gett the following exeption:
"Configuration system failed to initialize"
With the inner exception:
{"Unrecognized configuration section system.serviceModel. (C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Config\\machine.config line 137)"}
Line 137 in this file configures the ststem.web:
<system.web>
<processModel autoConfig="true"/>
<httpHandlers/>
<membership>
<providers>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<profile>
<providers>
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</profile>
<roleManager>
<providers>
<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
</system.web>
As all of my projects use an auto updater which uses a web service, i assume it has somthing to do with ASP.NET configuration...
Any ideas?
tnx
Roy
|
|
|
|
|
Hi All, (using Vb.net & VS 2008)
I have the following problem which has stumped me for the last few days :
I have a form with a Datagridview showing products ordered by customers over a 14 day period.
Also on the form I have an external combo box. The combo box is populated with customer names.
My plan is to have the user select a customer name via the external combo box then have the datagridview filtered with orders for the selected customer for the 14 days
So far, this is what is happening :
The Datgridview displays orders for All customers correctly over 14 days
The combo box displays a drop down list of All customers correctly
So far this is not happening :
Selecting a customer from the combo box doesn't change the datagridview to show only the selected customer orders. Orders from all customers show regardless of which customer is in the combo box selection.
Here is the code I am using :
-----------------------------------------------------------------------------------------------
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Dim connection As SqlCeConnection = New SqlCeConnection()
connection.ConnectionString = "Data Source=\SD Card\DB.sdf;"
connection.Open()
'Populate the orders datatable from the Order table
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT my select statement goes here", connection)
Dim mybindingsource As New DataTable
da.Fill(mybindingsource)
DataGridView1.DataSource = mybindingsource
'Populate the Combo Box with Cust ID & Names from the Account table
Dim cboda As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT ID, AccountName FROM Account", connection)
Dim cbods As DataSet = New DataSet
cboda.Fill(cbods, "Account")
Dim dt As New DataTable
dt.Columns.Add("ID", GetType(System.String))
dt.Columns.Add("AccountName", GetType(System.String))
Dim drcbods As DataRow
Dim drNewRow As DataRow
For Each drcbods In cbods.Tables("Account").Rows()
drNewRow = dt.NewRow()
drNewRow("ID") = drcbods("ID")
drNewRow("AccountName") = drcbods("AccountName")
dt.Rows.Add(drNewRow)
Next
cboCustomers.DropDownStyle = ComboBoxStyle.DropDownList
With cboCustomers
.DataSource = New DataView(dt)
.DisplayMember = "AccountName"
.ValueMember = "ID"
End With
-------------------------------------------------------------------------------------
I have the following code under the Combo box selectedValueChanged event
Private Sub cboCustomers_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCustomers.SelectedValueChanged
Me.myBindingSource.Filter = "Account_ID= '" & cboCustomers.SelectedValue.ToString & "'"
-------------------------------------------------------------------------------------
Fields in the Order datatable are : Account_ID, AccountName, Product_ID, ProductName, OdrQty1,......OrdQty14
Fields in the Account datatable are : ID, AccountName
In the underlying DB the Account and Order tables are linked via Account.ID = Order.Account_ID
I greatly apperciate any advice or assistance.
Many Thanks
Ku Mungi
|
|
|
|
|
Have you tried to used DataView[^] class as your datasource. Filtering is quite easy with that.
|
|
|
|
|
Thanks for the reply, I will check out the DataView class as suggested.
|
|
|
|
|
Mika Wendelius wrote: Have you tried to used DataView[^] class as your datasource. Filtering is quite easy with that.
I now have this working perfectly with a dataview and linq statement.
Thanks for pointing me in the right direction. Cheers
K
|
|
|
|
|