473,507 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shortest code footprint for .Parameter.Add?

Is there a way to replace the commented out parameter add syntax with a
single line of code, like the .Parameter.Add("@Letter"...) line below (which
does not work)?

'Dim prmLetter As New SqlParameter

'With prmLetter

' .ParameterName = "@Letter"

' .SqlDbType = SqlDbType.Char

' .Direction = ParameterDirection.Input

' .Value = chrLetter

'End With

With cmd

.CommandType = CommandType.StoredProcedure

.CommandText = "GetMasterIndexRowsWithLetter"

.Parameters.Add("@Letter", SqlDbType.Char, 1, chrLetter)

'.Parameters.Add(prmLetter)

End With

Thanks,

Dean Slindee
Nov 20 '05 #1
3 1865
Hi Dean,

You can use the following overload to create the parameter to add the
parameter to the SqlCommand.

SqlParameter p = SqlCommand.Parameters.Add(new SqlParameter(String,
SqlDbType, Int32, ParameterDirection, Boolean, Byte, Byte, String,
DataRowVersion, Object));

p.Value = chrLetter;

However, the value has to be set sepeartely.

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Dean Slindee" <sl*****@mindspring.com>
| Subject: Shortest code footprint for .Parameter.Add?
| Date: Thu, 13 Nov 2003 12:42:59 -0600
| Lines: 39
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <uZ**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 0-1pool36-7.nas14.milwaukee1.wi.us.da.qwest.net
63.156.36.7
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:156600
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| Is there a way to replace the commented out parameter add syntax with a
| single line of code, like the .Parameter.Add("@Letter"...) line below
(which
| does not work)?
|
| 'Dim prmLetter As New SqlParameter
|
| 'With prmLetter
|
| ' .ParameterName = "@Letter"
|
| ' .SqlDbType = SqlDbType.Char
|
| ' .Direction = ParameterDirection.Input
|
| ' .Value = chrLetter
|
| 'End With
|
|
|
| With cmd
|
| .CommandType = CommandType.StoredProcedure
|
| .CommandText = "GetMasterIndexRowsWithLetter"
|
| .Parameters.Add("@Letter", SqlDbType.Char, 1, chrLetter)
|
| '.Parameters.Add(prmLetter)
|
| End With
|
|
|
| Thanks,
|
| Dean Slindee
|
|
|

Nov 20 '05 #2
For more information, please refer to the following link:

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemDataSqlClientSqlParameterClassctorTopic 6.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| Newsgroups: microsoft.public.dotnet.languages.vb
| From: v-****@online.microsoft.com (Kevin Yu [MSFT])
| Organization: Microsoft
| Date: Fri, 14 Nov 2003 06:33:30 GMT
| Subject: RE: Shortest code footprint for .Parameter.Add?
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
|
| Hi Dean,
|
| You can use the following overload to create the parameter to add the
| parameter to the SqlCommand.
|
| SqlParameter p = SqlCommand.Parameters.Add(new SqlParameter(String,
| SqlDbType, Int32, ParameterDirection, Boolean, Byte, Byte, String,
| DataRowVersion, Object));
|
| p.Value = chrLetter;
|
| However, the value has to be set sepeartely.
|
| HTH. If anything is unclear, please feel free to reply to the post.
|
| Kevin Yu
| =======
| "This posting is provided "AS IS" with no warranties, and confers no
| rights."
|
| --------------------
| | From: "Dean Slindee" <sl*****@mindspring.com>
| | Subject: Shortest code footprint for .Parameter.Add?
| | Date: Thu, 13 Nov 2003 12:42:59 -0600
| | Lines: 39
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| | Message-ID: <uZ**************@TK2MSFTNGP10.phx.gbl>
| | Newsgroups: microsoft.public.dotnet.languages.vb
| | NNTP-Posting-Host: 0-1pool36-7.nas14.milwaukee1.wi.us.da.qwest.net
| 63.156.36.7
| | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:156600
| | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| |
| | Is there a way to replace the commented out parameter add syntax with a
| | single line of code, like the .Parameter.Add("@Letter"...) line below
| (which
| | does not work)?
| |
| | 'Dim prmLetter As New SqlParameter
| |
| | 'With prmLetter
| |
| | ' .ParameterName = "@Letter"
| |
| | ' .SqlDbType = SqlDbType.Char
| |
| | ' .Direction = ParameterDirection.Input
| |
| | ' .Value = chrLetter
| |
| | 'End With
| |
| |
| |
| | With cmd
| |
| | .CommandType = CommandType.StoredProcedure
| |
| | .CommandText = "GetMasterIndexRowsWithLetter"
| |
| | .Parameters.Add("@Letter", SqlDbType.Char, 1,
chrLetter)
| |
| | '.Parameters.Add(prmLetter)
| |
| | End With
| |
| |
| |
| | Thanks,
| |
| | Dean Slindee
| |
| |
| |
|

Nov 20 '05 #3
Thank you, that's what I needed.
Actually, you can enter the value on the same line too as shown below (works
for the one parm I tested below): I would rather the commented out line
worked, syntax is accepted, but get an error message (shown) when executing.
Nevertheless, glad to have one example that does work.
With cmd

.CommandType = CommandType.StoredProcedure

.CommandText = "GetMasterIndexRowsWithLetter"

'.Parameters.Add(New SqlParameter("@Letter",
SqlDbType.Char, 1, chrLetter)) 'Error returned: @Letter not supplied

.Parameters.Add(New SqlParameter("@Letter",
SqlDbType.Char, 1, ParameterDirection.Input, False, 0, 0, "",
DataRowVersion.Current, chrLetter))

End With

Dean Slindee

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:gE**************@cpmsftngxa06.phx.gbl...
For more information, please refer to the following link:

http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfSystemDataSqlClientSqlParameterClassctorTopic 6.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
--------------------
| Newsgroups: microsoft.public.dotnet.languages.vb
| From: v-****@online.microsoft.com (Kevin Yu [MSFT])
| Organization: Microsoft
| Date: Fri, 14 Nov 2003 06:33:30 GMT
| Subject: RE: Shortest code footprint for .Parameter.Add?
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
|
| Hi Dean,
|
| You can use the following overload to create the parameter to add the
| parameter to the SqlCommand.
|
| SqlParameter p = SqlCommand.Parameters.Add(new SqlParameter(String,
| SqlDbType, Int32, ParameterDirection, Boolean, Byte, Byte, String,
| DataRowVersion, Object));
|
| p.Value = chrLetter;
|
| However, the value has to be set sepeartely.
|
| HTH. If anything is unclear, please feel free to reply to the post.
|
| Kevin Yu
| =======
| "This posting is provided "AS IS" with no warranties, and confers no
| rights."
|
| --------------------
| | From: "Dean Slindee" <sl*****@mindspring.com>
| | Subject: Shortest code footprint for .Parameter.Add?
| | Date: Thu, 13 Nov 2003 12:42:59 -0600
| | Lines: 39
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| | Message-ID: <uZ**************@TK2MSFTNGP10.phx.gbl>
| | Newsgroups: microsoft.public.dotnet.languages.vb
| | NNTP-Posting-Host: 0-1pool36-7.nas14.milwaukee1.wi.us.da.qwest.net
| 63.156.36.7
| | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:156600
| | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
| |
| | Is there a way to replace the commented out parameter add syntax with a | | single line of code, like the .Parameter.Add("@Letter"...) line below
| (which
| | does not work)?
| |
| | 'Dim prmLetter As New SqlParameter
| |
| | 'With prmLetter
| |
| | ' .ParameterName = "@Letter"
| |
| | ' .SqlDbType = SqlDbType.Char
| |
| | ' .Direction = ParameterDirection.Input
| |
| | ' .Value = chrLetter
| |
| | 'End With
| |
| |
| |
| | With cmd
| |
| | .CommandType = CommandType.StoredProcedure
| |
| | .CommandText = "GetMasterIndexRowsWithLetter"
| |
| | .Parameters.Add("@Letter", SqlDbType.Char, 1,
chrLetter)
| |
| | '.Parameters.Add(prmLetter)
| |
| | End With
| |
| |
| |
| | Thanks,
| |
| | Dean Slindee
| |
| |
| |
|

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3232
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that,...
6
2080
by: Lau | last post by:
How do I easily calculate the shortest path between two geographical spots on a map? The map is divided into zones. So I guess it is possible to use Dijkstra’s Shortest Path algorithm, but it...
6
5870
by: ThanhVu Nguyen | last post by:
Hi all, I need recommendation for a very fast shortest path algorithm. The edges are all directed, positive weights. Dijkstra shortest path will solve it just fine but the if the graph is not...
20
16997
by: Webdad | last post by:
Hi! I running my first year as industrial engineer (informatics) We have an assignment to do : .... create a playfield (matrix). Some places in that field are blocked, so you can't pass them....
1
416
by: Derrick | last post by:
I am reading in xml files that equate to sql tables, via XmlDataDocument, and then operating on the DataSet. With the most simple app that just loads the xml doc, I see the memory footprint of the...
5
7380
by: leezard | last post by:
I am developing a program using VB.NET that will accept a start and end point, the system then will generate the shortest path to reach the end point. Anyone here have idea on doing this or some...
5
2859
by: costantinos | last post by:
Hello. I have implemented the Dijkstra shortest path algorithm, it works fine but I have one question on how I can improve something. I want to find all the possible shortest paths from a node...
2
3094
by: Bytter | last post by:
Hi everyone, I need to implement a very quick (performance-wise) Dijkstra shortest path in python, and found that libboost already has such thing. Problem is: I cannot find the installation...
5
3249
by: DBC User | last post by:
How would you develop a zero footprint application, is the smart client application a zero footprint application? Thanks.
0
7223
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
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.