Handling Long Strings - Change The Query / Structure And Test It?
Jul 9, 2010
I develop in VB and often I'm writing long TSQL statements in SSMS but getting them into VB is a bit of a pain. I like SSMS during development because I can change the query / structure and test it when there are problems. Some of them become stored proceduresand some of them I just keep in the code.
I like keeping them in the code because when I have a problem with something, I can GREP my projects directory and find the code that does something (that I've forgotten) or someone asks something about how something works, I can look it up. I've yet to find a GREP for stored procedures. Is there such a thing?I've read in a "best practices" white paper how we're not supposed to concatenate super long strings with & _
[code]...
C# handles these things much better than VB. I'm wondering how I can keep my code together during development and searchable later. I had my hopes up when VS 2010 offered implicit line continuation, that this would help my multi line SQL procedures.Again, I was mistaken. Perhaps I could write it all on one line. I'd be interested in knowing if there's a feature that I am not aware of. Well there are certainly many features which I'm not aware of, but I was referring to "long strings".
I develop in VB and often I'm writing long TSQL statements in SSMS but getting them into VB is a bit of a pain. I like SSMS during development because I can change the query / structure and test it when there are problems. Some of them become stored procedures and some of them I just keep in the code.I like keeping them in the code because when I have a problem with something, I can GREP my projects directory and find the code that does something (that I've forgotten) or someone asks something about how something works, I can look it up. I've yet to find a GREP for stored procedures. Is there such a thing?I've read in a "best practices" white paper how we're not supposed to concatenate super long strings with & _ but a hundred line proceure is a pain to nest in
sb.AppendLine(" WHERE [q3] IS NULL " sb.AppendLine(" AND [q4] > 2 "
[code]....
C# handles these things much better than VB. I'm wondering how I can keep my code together during development and searchable later. I had my hopes up when VS 2010 offered implicit line continuation, that this would help my multi line SQL procedures. Again, I was mistaken. Perhaps I could write it all on one line. I'd be interested in knowing if there's a feature that I am not aware of. Well there are certainly many features which I'm not aware of, but I was referring to "long strings".
I have a web request that can take 30-90 seconds to complete in some cases(most of the time it completed in 2-3). Currently, the software looks like it has hung if the request takes this long. I was thinking that I could use background worker to process the webrequest in a separate thread. However, The software must wait on the request to process before continuing. I know how to setup the background worker. What I am unsure about is how to handle waiting on the request to process.Do I need to create a timer to check for the results until the request times out or is processed?
Currently I have nunit's gui Test Structure setup to use Automatic Namespace suites.I was wondering if it was possible to group up method names inside the TestFixture.At the moment, the tree looks like
Below is a tiny program I modified from an example Microsoft code tutorial. This program simply copies .flac and .mp3 files from one specified folder to another, and if the file is already there it simply does not copy the file. I would like to make 2 changes to the program:
How would I go about making the error handling work (i.e. not crashing the program when an invalid input is made)?Also, a big change I would like to make would be for it to copy the folder structure and all files in the original folder (At the moment, it only copies files that are directly in the original folder, not files that are in folders inside the original folder).
I once again feel so angry about VB .NET . Here's what ruined my day :Lets say we have have a string variable :
Dim Var1 As String = "blablabla" If we want to replace something within it , we can use the Replace function : Dim Var2 As String = Replace(Var1,"a","o")
This works great . My problem appears when I want to replace the " character (double quote) . Thus , when using :Dim Var2 As String = Replace(Var1,"""","o")it will return an error .Of course you may wonder why I care to replace the " character . You see this string variable receives its value from a text box . Thus , if the user uses the " character , I want to replace it with two ' characters (single quote) . Is this replacement possible in .NET
In Visual Basic 2008 Express with SQL Server Compact 3.5 and the Usual DataSet / TableAdapters, My Query is too long:Changing the names, it is a query like this:
SELECT Table1.*, Table3.* FROM Table1 INNER JOIN Table2 ON Table1.ID = Table2.T1ID
[code].....
Problem is, Table1 and Table3 have around 10 and 5 columns each, with rather descriptive names, and The Table adapter is insistent on writing all the columns out and therefore hacks off my command. (It won't take * 's, it always says it can't find the column Table1.* )
I've written an SQL query with a lot of 'or's in the 'where' clause: i.e. "SELECT * FROM myTable WHERE col1='a' or col1='b' or col1='c'...etc" I'm trying to run a query in access via vb.net, but I keep getting "Query is too complex" error message. I'm guessing I've hit some maximum limit. Anyone know a way around this, other than just to break it down into multiple queries?
Is there a framework class that converts the partial day strings on these forums to a DateTime? Examples are "a few seconds ago", "19 minutes ago" and 3" hours 26 minutes ago",
I have a sql query which is returning null value below is the section the iID is null.Once debugger reaches this it goes to exception as its result is NULL. How to control debugger from going to the exception.
From r In ReceiptLines Where r.RECEIPT.RECEIPTDATE >= _reportStartDate And r.RECEIPT.RECEIPTDATE <= _reportEndDate
[Code].....
I am fetching all departments and their sales, average, count from the ReceiptLine, Receipt, ReceiptDiscount tables. The problem i am facing is, if i remove where discount > 0, I am getting null exception. But if I include that, then I only get sales that has discount. How would I write query that bring all sales less discount (if it has one).
I am using an Access database to store (filepaths to) pictures as well as comments people can leave on them. One picture can have multiple comments, so the tables look like this: _____________ _____________ |Photos | |Comments | |------------| |-------------| |Id (PK) | |Id (PK) | |PhotoPath | |PhotoId (FK) | |Description | |Comment | |____________| |_____________|
What I need to do now is retrieve a list of all Photos along with their Comments. So I have a class Photo with a collection of Comments: vb.net Public Class Photo Public Property Id As Integer Public Property PhotoPath As String Public Property Description As String Public Property Comments As List(Of Comment) End Class Public Class Comment Public Property Id As Integer Public Property PhotoId As Integer Public Property Comment As String End Class
I can retrieve the records using an INNER JOIN query (right?), as such; SELECT Photos.*, Comments.* FROM (Photos INNER JOIN Comments ON Photos.Id = Comments.PhotoId)
From the result of that, for each row in the result I can create a new Photo instance, set its properties and put it in a List(Of Photo) for further processing (displaying). However, how do I handle the Comments? With this query I would get a lot of duplicate Photos. I'd get a row for each comment, but most of these rows will represent the same photos... How do I handle this the best way? I have used inner join queries before, but only for a one-to-one relationship so I never had this problem before. Now when I finally need a one-to-many relationship I realize I've no idea how to handle this appropriately...
There must be some standard way of handling this? When I previously handled cases like this I didn't use an inner join, I just retrieved all Photos first, then iterate through them and run another query to retrieve the Comments that belong to that Photo (SELECT * FROM Comments WHERE PhotoId = ?). That works fine, but when the tables are getting larger it is getting noticeably slower. So I want to do it in a single query, I definitely want to avoid running hundreds of queries if I can.
How can I automatically change the font size of the label when the length of text exceeds the maximum width of the label?
Also, how do I set when that should stop? I mean obviously it can't keep getting smaller forever, so what would you advise I do when the text gets to a really small size? Just stop text entry? How?
I've got a common search button in my app that has the typical static magnifying image displayed on it. When the user clicks it I want the button's image to change to the animated search, to inform the user that the app is doing something (searching the database). Then when the search process is complete, change back to the static search image.
[code]...
When I comment out the line to change the button's image back to the static search image, (as stated above), and click the search button, the app actually performs the search, then when the search is completed, it changes the button's image.
Apparently VB or .Net is performing the under-the-hood process before the display/paint process, even though that's not the way it's coded. give me some insights on how to fix this, AND also please inform me of why this behavior occurs so I can try to avoid it in the future.
I am trying to test a number of stored procedures through SQL Server Query Analyzer. But am stuck when I try to test stored procedures that contain Output parameters.
I created a RDCL in the designer. I would like the User to Determine what is shown in the Report. How can I change the query at runtime? (ex. changing the customer Name)
This is the query that I have in the properties:
SELECT [Date], Address, Customer, Orders FROM Report_qry WHERE (Customer= 'JohnDoe')
How do I change the program path '"logic.txt", "G:"' in the code below to the OpenFileDialog.FileName? Cos when I tried it, I receive String conversion errors and I tried altering the codes but it didn't work out well. [code]...
Public Shared Function GetQueryStringValue(Of T As Structure)(ByVal queryStringVariable As String) As T Dim queryStringObject As Nullable(Of T) = Nothing If queryStringVariable <> Nothing Then If HttpContext.Current.Request.QueryString(queryStringVariable) IsNot Nothing Then queryStringObject = DirectCast(HttpContext.Current.Request.QueryString(queryStringVariable), T) End If
I have a question: How can I make a function or sub run inside a structure when a variable in this structure changes? As example I have this function: Public Structure Texture Sub New(ByVal TexturePath As String) Me.Path = TexturePath Me.Image = LoadImage(TexturePath) End Sub Public Path As String Public Image As Image End Structure
And somewhere this happens: Dim t As New Texture("path ooldfilename.tga") t.Path = "path o ewfilename.tga" I want it to automatically load the image when the "Path" variable changes. Is the only solution making an extra sub and run that? It would really decrease my code size if it changes on variable change.
Say I have a List(Of Tag) with Tag being an object. One member of Tag, Tag.Description, is a string, and I want to make a comma-separated concatenation of the Description members.Is there an easier way to do this than to read the Description members into a List(Of String) and then use the Join function?
Is there a easer way of coding in stead of wrighting long long paragraphs like this in one line [code]All of this is on one line and i got lots of info to put down.."The game will begin on your 16th birthday with your mother waking you up. Today you are to go to the castle for the first time. Leave your bed and open your dresser for a Strength Seed. "
So I have an array which holds instances of a structure. The structure contains various string properties.
I'm looking to modify each instance of a structure within this array by doing the following:
For Each stuInstance As StuInstance In arrStuInstances stuInstance.strCarName = "Benz"
But I found that this in fact fails to really change it permanently. If I do the following loops in the given order:For Each stuInstance As StuInstance In arrStuInstances
I have created two structures, one named "Product" and the other named "Item". These structures are quite similar but are at the same time quite different from each other. The structure definitions are as follows. Ultimately, I declare arrays in my containing class which access these structures as a type. Their declaration: "Products() as Product" and "Items() as Item". All has been fine and dandy until one day, I go to change the items Enabled() values, and something happens. Not only does it change the Items(index).Enabled(index) value, it does it on the corresponding Products(index).Enabled(index) value, even though it was never specified to do so. Also, nowhere in my coding have i defined this sort of thing to occur. It is rediculous, because I watch it happen. I turn on the watch window, and debug one step at a time, and every time, I watch the Item line step, I look down at the arrays of products and items, and both values have changed. How do I get this to stop, and only change the Item.Enable value??
<Serializable()> _ Public Structure Product Public Name As String