473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to join these 2 lines

Hello

How would I join these 2 lines of code, please?

Expand|Select|Wrap|Line Numbers
  1.  
  2. cmd.Parameters.AddWithValue("@uniqueCode", Convert.ToString(Request.QueryString("uniqueCode")))
  3.  
  4. cmd.Parameters.AddWithValue("@strEmail", Convert.ToString(Request.QueryString("strEmail")))
Thank you.
Apr 17 '18 #1
1 1754
jns42
3
When you say "combine", what is your end-goal? Are you trying to issue a single statement cover both?

If you have a collection of keys (e.g. "uniqueCode", "strEmail", etc) to be read, then you could loop through that collection, issuing the call above once for each key. (In case you aren't aware, the List is in System.Collections.Generic.)

So, if you had something like this defined:
Expand|Select|Wrap|Line Numbers
  1. Dim keys As List(Of String)
And then had it populated with all of the keys you're wanting to parse (i.e. keys.Add("uniqueCode") ), you could issue one statement inside of a loop, such as:
Expand|Select|Wrap|Line Numbers
  1. Dim key As String
  2. For Each key In keys
  3.     cmd.Parameters.AddWithValue("@" & key, Convert.ToString(Request.QueryString(key)))
  4. Next key
`

I hope this helps.

-J

EDIT: It may also be of interest to note that (in VB.Net, anyway) the List(...) types have a "ForEach" method on them that makes the same loop, so the above code could also be written as:
Expand|Select|Wrap|Line Numbers
  1. keys.ForEach(cmd.Parameters.AddWithValue("@" & key, Convert.ToString(Request.QueryString(key))))
Apr 18 '18 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a...
17
by: Douglas Alan | last post by:
Is there a canonical way of iterating over the lines of a file that are null-separated rather than newline-separated? Sure, I can implement my own iterator using read() and split(), etc., but...
6
by: Rowan | last post by:
Hello, I am having a problem with a join. Either I am just not seeing the obvious, it isn't possible, or I need to use a different approach. I have an application with a vsflexgrid that needs...
4
by: Anna Smith | last post by:
I have an extremely long and complex select statement as shown below and I need to split it onto two lines but not quite sure how to do it because I've never needed to before. I need to split it...
2
by: paulmac106 | last post by:
Hi, I have 2 tables: tblStatements and tblLines (one to many) Any tblStatements record can have many associated records in tblLines. The search criteria is against tblLines (ie...
3
bvdet
by: bvdet | last post by:
I wrote a script that extracts line and circle data from an Autocad DXF file:## GridDXF.py Version 1.02 ## Copyright (c) 2006 Bruce Vaughan, BV Detailing & Design, Inc. ## All rights reserved....
4
by: Newbie19 | last post by:
I've searched a few websites and none of them meantion how to break up really long lines of code like a sql query. The sql statement looks like this (I've broked it down so it can fit in the...
3
by: booyeeka | last post by:
on a windows form, i have RichTextBox, with some text, in several lines. and one button on a form. i wolud like when i click on that button, to join all richtextbox of lines in one line, but not...
0
by: sivacak | last post by:
Hello, I have wrote a stored procedure but its real slow. Its activated by a dropdownlist on web page but its takes to long to process. How to access faster in asp pages. CREATE PROCEDURE ....
1
by: dar102 | last post by:
I need to generate permutation of some words (A T G C ) actually nucleotides for di-composition (eg AA AT AG AC), tri-composition (AAA AAT AAC AAG), tetra, penta etc (one at a time) and then check in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.