376 Posted Topics
Re: I suggest to people all the time to use parameterized queries. Cross-forum. C#, VB, ASP.NET. Just now in Java. I never use them. [I]Scandalous.[/I] *They don't fit how I've developed my reusable data access code and how I generally program data-bound objects. However, I've kicked around ideas of how to … | |
Re: Perhaps this will give you an idea of how to solve your problem. [CODE] using System; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int[] values = new int[] { 1, 5, 3, 5, 5, 4 }; var query = (from value in values group … | |
Re: I believe you're going to have to get a count from the images table before you join to the products table, and then you can use the ifnull function to make the count 0 where it may be null. [CODE] select p.prod_id, ifnull(x.img_count, 0) as img_count from products p left … | |
Re: [QUOTE=Cardinals1980;1145291]Can someone help me with this, having trouble with loops. I need to write a program that prints every integer value from 1 to 20, along with its squared value. Thanks for any assistance.[/QUOTE] What [I]type[/I] of problem are you having? Can you not figure out the logic or do … | |
Re: To add to what jbisono posted, I would recommend adding a check for null to the FindByText method to account for the possibility that a previously selected item is no longer in the list of available items. So it would be something like [CODE] ListItem listItem = cblTest.Items.FindByText(st); if (listItem … | |
Re: Personally, I prefer no brackets on a one-line block. I realize it's just a preference thing, but just as whitespace in code is good, too much is annoying. However, I won't mismatch brackets on if-else blocks. Meaning if one of the blocks is multiple lines of code, then the single-line … | |
Re: If you have a setting called tb1 of type string, you should be able to clear and save it like this: [CODE] Properties.Settings.Default.tb1 = string.Empty; Properties.Settings.Default.Save(); [/CODE] | |
Re: You can look up javascript functions to disable right clicking on a web page. You can look up ways to limit menu options, you can even use javascript to open pages with no address or menu bars altogether. Look the functions up via google, although it's not guaranteed you'll find … | |
Re: Consider Linq to XML! Example code: [CODE] using System; using System.Linq; using System.Xml.Linq; class Program { static void Main(string[] args) { string xml = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Teams> <Team City=""Chicago""> <Name>Bulls</Name> <LastChampionship>1998</LastChampionship> </Team> <Team City=""Los Angeles""> <Name>Lakers</Name> <LastChampionship>2009</LastChampionship> </Team> <Team City=""Boston""> <Name>Celtics</Name> <LastChampionship>2008</LastChampionship> </Team> <Team City=""San Antonio""> <Name>Spurs</Name> <LastChampionship>2007</LastChampionship> … | |
Re: To concur with Ryshad, walk before you run. Get a beginner's book, start with the standard Hello World program, and get the fundamentals down. Database programming isn't for the completely untrained novice. | |
Re: The quick glance indicates that your code references Img1.Visible, yet the name of the object is simply Img. | |
Re: ViewState of a page is managed between the Init and Load events. You are right, by prepopulating those fields during the Page_Load handler, you are essentially overwriting the changes the user is making. One option is to move the prepopulation of those fields to the Page_Init handler, that will allow … | |
Re: [QUOTE=jamesphi;1141925]When you are using the tab to enter a textbox, How do you [B]select all [/B]the text so when you begin typing it eliminates the old text?[/QUOTE] Use TextBox.[B]SelectAll()[/B] on the Enter event. Sample implementation, two controls using the same handler. [CODE] Private Sub TextBox_Enter(ByVal sender As System.Object, ByVal e … | |
Re: objReader is declared but not instantiated (or otherwise given an initial value) before the try/catch/finally block. When objReader.Close() is referenced in the Finally block, the object is not guaranteed to have been instantiated because an exception could have thrown before the object is successfully instantiated in the Try block. A … | |
Re: Egad! Put the "if" statement in the code behind around the LoadControl call and do not under any circumstances use the <% %> coding mechanism. The horror! But here's a full working example. [CODE] <%@ Page Language="C#" AutoEventWireup="true" CodeFile="loadcontroldemo.aspx.cs" Inherits="loadcontroldemo" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html … | |
Re: The two main things to escape in the MySQL world are the single quote (common across virtually all DBs) and the backslash (specific to MySQL). You can do this yourself, assuming you've also validated that you're working with the right data types to start with (in other words, don't [I]fix … | |
Re: Create a loop. It should execute as long as it finds instances of your search text. With each iteration, it starts the next search after the previous starting location. When the text is not found, .Find(...) returns -1, and the loop will exit. [CODE] Private Sub Button1_Click(ByVal sender As System.Object, … | |
Re: Are you in the root folder of the website and/or web application? Meaning: Do you have [url]www.yourwebsite.com[/url] or is it a situation like [url]www.sharedwebsite/yourdirectory?[/url] In the case of the latter, did the website owner configure "yourdirectory" as its own application in IIS? You need to have a web.config file in … | |
Re: Here is some code I use to abbreviate text. I wrote it for a recent project, but I haven't really tried to optimize it. To be honest, I haven't thoroughly tested it! (Yet.) It is similar to what has been posted before, but I add a regular expression to it … | |
Re: I'm not quite sure what your specific requirements are based on the description. If, for example, you are allowing your users to specify line numbers for the start and end of the block, you could use LINQ and extension methods to accomplish the goal. This is a sample. First, my … | |
Re: [CODE]foreach(ArrayList item in arrList)[/CODE] The above line suggests that arrList stores more ArrayList objects. However, your exception indicates that the contents of arrList are actually string arrays. Your code could be the following: [CODE] foreach(string[] item in arrList) [/CODE] Which would only cause an exception if there was something in … | |
Re: Console.Read() is giving you the [I]integer value[/I] of the [I]character[/I] the user entered. 0-9 in ASCII is 48-57. If the user entered a capital letter, you'd get 65 to 90. Lower case, 97-122. If you want the true value of what the user entered, especially if you're anticipating an entry … | |
Re: The FileUpload control has a .SaveAs(fileName) method. Save the file to the server, and then you can use a StreamReader (System.IO.StreamReader) object to read and work with the contents of the file. | |
Re: Try getting the .NumberFormat property of the cell. Consider this adaptation of your code (at line 16) as my test. I created a worksheet and put the value 1 in cell A1. I formatted it to three decimal places. [CODE] double d = double.Parse((range.Cells[1, 1] as Microsoft.Office.Interop.Excel.Range).Value2.ToString()); string s = … | |
Re: How much have you done so far? Have you tried to put together an algorithm, even if just in pseudocode, for what you are trying to accomplish and how you might think to achieve it? | |
Re: [QUOTE=scias23;1138417]i have many textboxes in my form, now i want to validate the data inside it. how can i achieve this other than the try catch? i want the validation to be usable in all my forms so i'll write it as a sub/function. any suggestions?[/QUOTE] What specifically are you … | |
Re: You an use System.IO.File.GetCreationTime(filename) to get when a particular file was created. Compare that to today's date and delete as necessary. You can then open a file with append access via a StreamWriter to write to a file. If the file exists, it will merely be appended to. If not, … | |
Re: + is the string concatenation operator in C#, which is the language of the thread you referred to. & is the concatenation operator for VB. You can certainly use it in your problem. | |
Re: Look into [U]LINQ to XML[/U]! You can use it to load XML files or parse XML strings (with XML namespaces) into collections of defined or anonymous types. Example: [CODE] Imports System.Linq Imports System.Xml.Linq Module Module1 Sub Main() Dim xml As String = "<?xml version=""1.0"" encoding=""utf-8"" ?>" & _ "<Cars>" & … | |
Re: As a little "getting to know your IDE" tip, you can type in the classes you see mentioned into your code and find the right namespace if it has not already been referenced. Sometimes this can lead you astray, as class names are ambiguous across namespaces from time to time, … | |
Re: Look at the System.Collections.Generic namespace. There are lists, stacks, key/value dictionaries, etc. VB usage example: [CODE] Imports System.Collections.Generic Module Module1 Sub Main() Dim names As List(Of String) = New List(Of String) names.Add("Jack") names.Add("Jill") Dim romanNumerals As Dictionary(Of Integer, String) = New Dictionary(Of Integer, String) romanNumerals.Add(1, "I") romanNumerals.Add(2, "II") romanNumerals.Add(3, "III") … | |
Re: Keep the analytics script on your page as you would otherwise have it. Then you can use the OnClientClick attribute of the ImageButton and make a google analytics JS call from there. We typically use that when a form submits offsite, for example. We want to track users as they … | |
Re: You're probably going over the maximum value of an integer. Consider the following two code samples. [CODE=C#] static void Main(string[] args) { int max = int.MaxValue; max++; Console.WriteLine(max); Console.Read(); } [/CODE] [CODE] Sub Main() Dim max As Integer = Integer.MaxValue max += 1 Console.WriteLine(max) Console.Read() End Sub [/CODE] Aside from … | |
Re: Is this a client-server type application, or is it simply multiple instances of an application independently operating on users' workstations? In the case of the former, you can try using event notifications. When one user updates the data, an event is fired and the other clients refresh the data as … | |
Re: [QUOTE=Yamazaki;1132868]I noticed most of the decent inventory systems are built with VB. Why?, does it offer simpler deployment, unsophisticated data storage than MsSQL, and easy reports generation?.[/QUOTE] In the present age, VB and C# are on equal ground in terms of usefulness in business development. Keep in mind, however, that … | |
Re: You are going down the right path with your alternate idea. If a consultant can have multiple experiences [I]and[/I] an experience can have multiple consultants, then you have a many-to-many relationship between consultants and experiences, and you would express that relationship in the form of a matching table. The same … | |
Re: Here's some code that does the work that would be compatible between VB and C# (syntax aside) [CODE] Sub Main() Dim pastDate As DateTime = New DateTime(2010, 1, 1) Dim targetDate As DateTime = New DateTime(2010, 1, 31, 23, 59, 59) Dim currentDate As DateTime = DateTime.Now 'percentage in this … | |
Re: [QUOTE=Garrett85;1133588] I see that you can specify what attributes the child class inherits based on it's parent class through parameters. But what if you specify the base class but insert no parameters? Does it then it none, or all of the like the original class? Thanks. [/QUOTE] This could be … | |
Re: This works for me. [CODE] long number = 100072305608500L; string format = "##0/00-00-000-00W0/##"; string output = number.ToString(format); [/CODE] | |
Re: [CODE] Human h2 = new Man(); [/CODE] In this situation, this is legal when Man is a derived class of Human. [CODE] class Program { static void Main(string[] args) { Human h2 = new Man(); h2.Name = "DaniWeb User"; } } public class Human { public string Name { get; … | |
Re: Your program ends after Add because when it returns to main, there is nothing left after the switch statement. From the looks of it, you want the program to keep executing unless someone selects the Exit option. You should enclose the functionality of your main method within a loop that … | |
Re: Add an "Or" clause to your loop exit criteria. Example: [CODE] Sub Main() Dim i As Integer = 0 Dim j As Integer = 0 Do Until i > 100 Or j > 120 i += 3 j += 5 Loop Console.WriteLine("i: {0}", i) Console.WriteLine("j: {0}", j) Console.Read() End Sub … | |
Re: You can include the same table multiple times in a query as long as you alias it. In this case, you'd include it a total of three times and join it to itself. The below should work, although I haven't tested it. [CODE] Select t1.ID From Testtable t1 Inner Join … | |
Re: [QUOTE=asprin;1131526]I'm new to C#. I was wondering if using a Switch case statement would be more handy in this case or not? Wouldnt it narrow down the usage of if-else statements?[/QUOTE] In my view, switch case and if/else-if structures are functionally equivalent, the latter has the bonus of not needing … | |
Re: By placing 1 inside single quotes, you're treating it as a string, but the destination field is an int. That's a syntax error. | |
Re: Your syntax indicates that the scripts folder is two levels up from your aspx page. Is that the actual case? Meaning, you'd have a directory structure like this /Scripts/scripts.js /somedirectory/somedirectory/yourpage.aspx | |
Re: Convert.[B]To[/B]Int32 You're also going to have a problem on the last line. You've got a set of parentheses you don't need and there's a + symbol you're lacking that you [I]do[/I] need. | |
Re: DAO and ADO have been replaced by ADO.NET, and it's a significant change, but easy to adjust to. If you're connecting to Access, the connection string you've probably been using in VB6 is more than likely sufficient for VB2005. The objects you're going to want to look at would be … | |
Re: I suggest setting up an array of objects to represent your "used money bills" (and their counts). You can then execute a loop for each of those bills and calculate (a) how many of a given bill would be used and (b) what would be left after those bills were … | |
Re: One recent thread you might want to look at is this one on [URL="http://www.daniweb.com/forums/thread260002.html"]instantiating on object[/URL], because it deals with inheritance, as well. As for this particular example, it looks like the code is missing the definition of the Critter class. From the code example, it looks like it should … |
The End.