376 Posted Topics

Member Avatar for coloradoboy2

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 …

Member Avatar for soccerjerseys
-5
140
Member Avatar for brettbed

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 …

Member Avatar for brettbed
0
486
Member Avatar for jasystweb

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 …

Member Avatar for jasystweb
0
154
Member Avatar for Cardinals1980

[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 …

Member Avatar for ddanbe
0
106
Member Avatar for ALRamarao

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 …

Member Avatar for jbisono
0
1K
Member Avatar for abarlowa

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 …

Member Avatar for herbie643
0
84
Member Avatar for Cory_Brown

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]

Member Avatar for Cory_Brown
0
116
Member Avatar for ma.ali786

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 …

Member Avatar for apegram
0
152
Member Avatar for templersstorms

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> …

Member Avatar for templersstorms
0
173
Member Avatar for badx

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.

Member Avatar for apegram
-1
156
Member Avatar for boycuoi
Member Avatar for boycuoi
0
204
Member Avatar for gicker1977

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 …

Member Avatar for apegram
0
103
Member Avatar for jamesphi

[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 …

Member Avatar for apegram
0
82
Member Avatar for rajabca

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 …

Member Avatar for apegram
-1
118
Member Avatar for manish_partey

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 …

Member Avatar for manish_partey
0
89
Member Avatar for TheWhite

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 …

Member Avatar for BestJewSinceJC
0
146
Member Avatar for wasyazwan

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, …

Member Avatar for wasyazwan
0
2K
Member Avatar for gdp_87

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 …

Member Avatar for gdp_87
0
95
Member Avatar for adamjw3

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 …

Member Avatar for apegram
0
1K
Member Avatar for deathtoall141

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 …

Member Avatar for Geekitygeek
0
196
Member Avatar for snakay

[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 …

Member Avatar for snakay
0
153
Member Avatar for bzupnick

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 …

Member Avatar for Geekitygeek
0
113
Member Avatar for dawsonz

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.

Member Avatar for kvprajapati
0
194
Member Avatar for sjfleming

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 = …

Member Avatar for sjfleming
0
8K
Member Avatar for nickelmann

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?

Member Avatar for nickelmann
0
2K
Member Avatar for scias23

[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 …

Member Avatar for apegram
-1
104
Member Avatar for hitro456

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, …

Member Avatar for hitro456
0
145
Member Avatar for automata

+ 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.

Member Avatar for k1robert
0
164
Member Avatar for k1robert

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>" & …

Member Avatar for k1robert
0
964
Member Avatar for JamesGeddes

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, …

Member Avatar for jonsca
0
249
Member Avatar for AirGear

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") …

Member Avatar for AirGear
0
193
Member Avatar for learningdotnet

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 …

Member Avatar for learningdotnet
0
766
Member Avatar for gangsta1903

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 …

Member Avatar for gangsta1903
0
2K
Member Avatar for eURe

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 …

Member Avatar for eURe
0
2K
Member Avatar for Yamazaki

[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 …

Member Avatar for Diamonddrake
0
110
Member Avatar for garcon1986

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 …

Member Avatar for apegram
0
237
Member Avatar for kalehl

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 …

Member Avatar for kalehl
0
361
Member Avatar for lewashby

[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 …

Member Avatar for apegram
0
96
Member Avatar for scottlafoy

This works for me. [CODE] long number = 100072305608500L; string format = "##0/00-00-000-00W0/##"; string output = number.ToString(format); [/CODE]

Member Avatar for DanielGreen
0
131
Member Avatar for fxpepper

[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; …

Member Avatar for kplcjl
1
558
Member Avatar for ZER09

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 …

Member Avatar for ZER09
0
127
Member Avatar for mikeandike

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 …

Member Avatar for mikeandike
0
115
Member Avatar for Yeen

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 …

Member Avatar for Yeen
0
2K
Member Avatar for HiImBen

[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 …

Member Avatar for kplcjl
0
135
Member Avatar for xxmp

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.

Member Avatar for xxmp
0
99
Member Avatar for nccsbim071

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

Member Avatar for mitulmodi.rcc
0
168
Member Avatar for abarlowa

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.

Member Avatar for abarlowa
0
1K
Member Avatar for ananthaninfo

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 …

Member Avatar for ananthaninfo
0
116
Member Avatar for Nerathas

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 …

Member Avatar for ddanbe
0
122
Member Avatar for lewashby

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 …

Member Avatar for apegram
0
146

The End.