Jump to content
Xtreme .Net Talk

Kurt

Avatar/Signature
  • Posts

    101
  • Joined

  • Last visited

Everything posted by Kurt

  1. Have a look at the 'RowFilter' property of the DataView object. You could use the RowFilter of the DefaultView object like this.... dataset.datatable.DefaultView.RowFilter = "Name = 'Jhon'" and than check the Count property of the DefaultView object to see if it's bigger than 0 if (dataset.datatable.DefaultView.Count > 0) { // the name was found }
  2. Hi, I have a DataSet with a DataTable of the folowing format (fields): timestamp, value I would like to find 1 specific value in the DataTable, based on a timestamp the user provides. For example: 17th august 2004, 23:00 I tried some different things like; dataSet.dataTable.DefaultView.RowFilter = "timestamp = '2004/08/17 23:00:00'" but then the Count property of the DefaultView becomes 0! The DataTable contains the value though, and the RowFilter expression works fine when I use it in the WHERE clause of a T-SQL statement and request the data directly from the database... What am I doing wrong? Is there a way to specify a DateTime value to search on?
  3. http://mathforum.org/dr.math/faq/faq.sqrt.by.hand.html
  4. thanks, guess this closses the thread
  5. So you make a physical directory where you want, then make manually a virtual directory pointing to that directory and then start a new ASP.NET project with the name of the virtual directory?
  6. I would like to know how to change the default behaviour of VS when creating a new ASP.NET application. When creating such a project, VS creates a virtual directory in IIS that points to some physical directory under 'inetpub\wwwroot'. Is it possible to let visual studio create a virtual directory in IIS that points to some folder under MyDocuments or any other directory where I would like the project to be created?
  7. I thought shared (static) methodes only could use other static members. The constructor must be an exception then, or is actually always static from nature. Logical enough, otherwise an instance would be needed to create an instance...
  8. Ok, but what if I get some person data like Name Address City Country Phone1 .....etc. Suppose I keep Countries with their Cities in a separate table that has a CityID field (autogenerated by SQL) for each row. In the Persons table I simply have this CityID as a foreign key to save the city and country the person lives in. If a user types in a combination of a city and a country that is not know in the database yet (assume that his input is correct), what is to be done then? Should I first take the data about Country and City in a dataTable in the dataset, then update the underlying database which will create a unique CityID for the new entry and then in some way (how???) retreive this unique value so it can be written to the 'CityID'-field of the new person's entry in my offline dataset (as foreign key)? In that way I will need to connect every time a new City/Country combination is filled in by a user - so the offline dataset would pretty much lose its value. This goes by the way for all 'related' information in the database... I know that after a while (a matter of time) most Countries/Cities combinations will be known so the ID field can be collected from the offline dataTable, but as relational databases are build on the principle of relations I can imagion that these situation must occure quiet frequently.
  9. A user of my class needs to supply some information to the constructor of the class. Then the constructor checks if the parameters that where passed can describe a valid instance or not. If not I give the user a warning, but I would also like to drop the creation of the object itself - as if the constructor was never called! Is this possible?
  10. So in their local dataset, two users could get/fill in the same value in the primary key field for newly created entries, one on one users machine and the other one on the others pc, but when the update methode is called by both users, the dataatapter will resolve the problem and make sure that the primary key is unique for each entry? Or will the database simply reject the update action?
  11. General question: To keep this simple, suppose I have a database with 1 table. The primary key in the table is autogenerated by the database for each new entry. If I now fill a datatable in a dataset with the entries of the table using a dataadapter and I want to add a row, does ADO.NET then generate the unique primary key itself? More over, if 2 users do the same.... they both add a record in the datatable - then they probably get the same 'unique' key created in their off-line dataset. What happens when the underlying database table is updated? Does ADO.NET know that the new entries each should get a new unique number? And what if there is another table that has the primary key of the first table as a foreign key? Will ADO.NET add a new entry in the first table for the first user - and use the key assigned by that opperation in the depending table - while the second user will get another unique key in the first table and use that one as the foreign key in the second table?
  12. This code piece doesn't seem to do the trick for me. Do I need to log in to Hotmail first? Or should I be able just to use the hotmail SMTP server without further?
  13. Might it be that this has something to do with the project type that I started? I just wan't to make a class that I can use in other projects, so I started a ClassLibrary-project in C#. (Visual Studio .NET 2000). I had to add a windows form in the project however, that just acts as a container for the MSComm32.ocx ActiveX. In the Modem class, I then wanted to create a variable of the type AxMSCommLib.AxMSComm and to instantiate that variable by giving a reference to the ActiveX object on the container form. This is necessary because if you only make a variable of that type and instantiate it by running the constructor (New AxMSCommLib.AxMSComm()) the code seems to work, but the control will not be installed/registered on the target machines where the application will run on. By putting it on a form, just like in VB6, Microsoft seems to give a free runtime license to the installing machine. I recently stepped from VB.NET to C#. In VB.NET I have done this trick before. I just wonder if C# has a problem with that specific ActiveX, or if I maybe should change the project type. Maybe ClassLibrary project should never contain Windows Forms?
  14. I imported the MSComm ActiveX from VB6 to create a modem object. But C# generates folowing error message when the test program is run. (no compiler warnings) An unhandled exception of type 'System.Threading.ThreadStateException' occurred in system.windows.forms.dll Additional information: Could not instantiate ActiveX control '648a5600-2c6e-101b-82b6-000000000014' because the current thread is not in a single-threaded apartment. First time I hear about single-threaded apartment, anyone knows what I can do to solve this? Or some general background information...
  15. You could overload the constructor of your class to create a copy-constructor. It would take an object of the same type as parameter and then copy the state of the object passed to the newly created object. Public Class cl1 Public Sub New() End Sub Public Sub New(ByVal first As Integer, ByVal second As Integer) Me.someValue1 = first Me.someValue2 = second End Sub 'The Copy-constructor Public Sub New(ByVal toCopy As cl1) Me.someValue1 = toCopy.someValue1 Me.someValue2 = toCopy.someValue2 End Sub Public Overrides Function ToString() As String Return "(" + Me.someValue1.ToString() + "," + Me.someValue2.ToString() + ")" End Function Private someValue1 As Integer Private someValue2 As Integer End Class Public Class Tester Public Shared Sub Main() Dim obj1 = New cl1(2, 3) Dim obj2 obj2 = New cl1(obj1) Console.WriteLine(obj1.ToString()) Console.WriteLine(obj2.ToString()) End Sub End Class
  16. You could have a look for TAPI (telephone application programmers interface). When working with modems, you could also send and receive Hayes commands over the serial port (COM1 for example). The .NET framework has no build in support for serial ports (outdated technology or something), but you could import the VB6 ActiveX MsComm32.ocx
  17. Kurt

    byte and Byte

    A letter or a number can't be represented by a bit! 1 bit is either 0 or 1. A byte is a sequence of 8 bits. In older programming languages, a character is represented by a byte that contains the ascii code for that character. In .NET however, characters are represented by their unicode value.... And a number like an int (Int32) is stored in memory in 4 bytes....
  18. Have a look at the RegEx class in the System.Text.RegularExpressions namespace. It's constructor takes a string representing a regular expression. The object created exposes a Split methode.... Can't tell you exactly how to solve your problem, but I guess the help files on RegEx could help you on the way. Regular expressions are very powerfull and are used in languages such as Perl...
  19. I assume that solving it with a dataset wouldn't be to hard. You could probable itterate through the row with some kind of loop. But why would you like to create redundant data in the database. One of the first advices in creating relational databases would be to avoid 'double' data.
  20. It shouldn't need it, but an exception shouldn't be thrown either when ToString() is called - a methode overritten by the String class, no harm to call it - and this while... System.Console.WriteLine(System.String.Empty.ToString()); doesn't throw any exceptions. ps: I know that strings are immutable, and so act like value types when passed to a methode. On the other hand however, System.String doesn't inherit from System.ValueType as value types seem to do... some more info is very welcome....
  21. I wonder why the .ToString() methode of line 20 failes.... Some more questions; 1/ Is a string actually a value type or a reference type? 2/ If a string is a value type, what is the default initial value for the strings of an array of strings that is instantiated ("", null or String.Empty???)? 3/ And what is the value of the Exception.HelpLink string when not specified? By the way, ToString() seems to work on String.Empty.... [CS] namespace Tests { using System; public class Test { public static void Main() { try { double a = 6; double b = 0; Console.WriteLine("{0} / {1} = {2}",a,b,Divide(a,b)); } catch (DivideByZeroException divByZero) { //the folowing line WORKS, HelpLink property is seen as "" (empty string) Console.WriteLine("Help on error: '{0}'\n\n",divByZero.HelpLink); //the folowing line THROWS AN EXCEPTION, WHY ???? Console.WriteLine("Help on error: '{0}'\n\n",divByZero.HelpLink.ToString()); } } public static double Divide(double a, double b) { if (b == 0) { DivideByZeroException e = new DivideByZeroException("Argument b was 0 in DoDivision (dividing by zero)"); //folowing line is commented to see what the HelpLink property contains by default.... //e.HelpLink = "More about dividing by zero..."; throw e; } return a/b; } } } [/CS]
  22. Hi Robby, I started this thread under the Systax Related subjects for C#, with thread name 'finally'. It seems to be moved to the general pages, but there it got the thread name "DataView RowFilter Hell". I have been reading on the "DataView RowFilter Hell" thread today, but I did not start that thread, and it handled about complete different subjects. Now, I find our discussion under the general subjects with thread name "DataView RowFilter Hell", of which I would be the thread starter.... Any idea whats going on?
  23. Thanx, I see now... very important when rethrowing exceptions.... namespace Tests { using System; public class tryApp { private static void Main() { try { Console.WriteLine("Something is about to go wrong"); int a = 6; int b = 0; Console.WriteLine("Division = {0}", a/b); } catch { Console.WriteLine("Let me handle this"); throw; } finally { Console.WriteLine("I always run..."); } Console.WriteLine("And does this run?"); } } }
  24. Both seem to work exactly the same to me namespace Tests { using System; public class tryApp { private static void Main() { try { Console.WriteLine("Something is about to go wrong"); int a = 6; int b = 0; Console.WriteLine("Division = {0}", a/b); } catch { Console.WriteLine("Let me handle this"); } finally { Console.WriteLine("I always run..."); } Console.WriteLine("And does this run?"); } } }
  25. finally Is the working of the following two pieces of code equivalent(concerning the code that's executed no matter an exception is thrown or not)? Or is there a difference other than pure syntactical dispute? namespace Tests { using System; public class tryApp { private static void Main() { try { // some code that could throw an exception } catch { // handle the exception } finally { // run clean up code IN FINALLY BLOCK } } } } namespace Tests { using System; public class tryApp2 { private static void Main() { try { // some code that could throw an exception } catch { // handle the exception } // run clean up code OUT OF TRY BLOCK } } }
×
×
  • Create New...