473,397 Members | 1,985 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,397 software developers and data experts.

hard quetion parameter

I have this :

dim cmd as new sqlcommand("Insert into (value1, value2) VALUES
(@value1, @value2)", myConnexion)
with cmd
..parameters.add("@value1", sqldbtype.nvarchar, 50).value = "me"
..parameters.add("@value2", sqldbtype.nvarchar, 50).value = "you"
end cmd

Is it possible now to have a string like with a property of cmd ?

insert into(value1,value2) VALUES ('me', 'you') ?

Nov 21 '05 #1
5 855
Hi,

Your first method is recomended both should work fine. If your parameter is
fixed than I see no reason why not to do it in the second way. I read often
here to prevent SQL insertions, however that is AFAIK if you have not added
the SQL2000 server SP3.

I am not complete sure of the last.

Cor
Nov 21 '05 #2
no you don't undestand what i want

i do the first method

but i want to store the real one in a Array (to update another
database)

so i use always

dim cmd as new sqlcommand("Insert into (value1, value2) VALUES
(@value1, @value2)", myConnexion)
with cmd
..parameters.add("@value1", sqldbtype.nvarchar, 50).value = "me"
..parameters.add("@value2", sqldbtype.nvarchar, 50).value = "you"
end cmd
but after i do this i want to have it in a single string to store it in
a array

undertand ?

Nov 21 '05 #3
If the parameters are always fixed, then no you shouldn't be susceptible to
Injection attacks. However, it's good practise to always use parameters (or
stored procedures) anyway.

Have a read of http://msdn.microsoft.com/msdnmag/is.../SQLInjection/
for more information.

Jevon
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,

Your first method is recomended both should work fine. If your parameter
is fixed than I see no reason why not to do it in the second way. I read
often here to prevent SQL insertions, however that is AFAIK if you have
not added the SQL2000 server SP3.

I am not complete sure of the last.

Cor

Nov 21 '05 #4
In other words, sqlUpdateCommand1.CommandText simply returns the sql
command
without the parameter values. Is there a way to see the sql statement
with
the parameter values once the parameters have been populated?

Nov 21 '05 #5
ucasesoftware wrote:
no you don't undestand what i want

i do the first method

but i want to store the real one in a Array (to update another
database)

so i use always

dim cmd as new sqlcommand("Insert into (value1, value2) VALUES
(@value1, @value2)", myConnexion)
with cmd
.parameters.add("@value1", sqldbtype.nvarchar, 50).value = "me"
.parameters.add("@value2", sqldbtype.nvarchar, 50).value = "you"
end cmd
but after i do this i want to have it in a single string to store it
in a array

undertand ?


dim cmd as new sqlcommand("Insert into (value1, value2) VALUES (@value1,
@value2)", myConnexion)

dim s as string=cmd.CommandText
cmd.parameters.add("@value1", sqldbtype.nvarchar, 50).value = "me"
s.Replace("@value1", "'" & "me" & "'")
cmd.parameters.add("@value2", sqldbtype.nvarchar, 50).value = "you"
s.Replace("@value2", "'" & "you" & "'")

String s now contains "Insert into (value1, value2) VALUES ('me', 'you')"

But then you lose the safety of a parameterized query when you update the
other database.

If you're storing it in an array, you might as well store enough information
to be able to use a parameterized query again.

Andrew
Nov 21 '05 #6

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

Similar topics

1
by: Luke Airig | last post by:
I have an xsl stylesheet that merges data from two files based upon a common date/time field. Right now, one of the file names is hard-coded in the xsl file. Is there any way to make this...
10
by: Nick L | last post by:
I'm working on a function which creates a pointers to an array of unsigned ints based off a number read from a file. I then continue to read file names from the file, convert the name to a char*...
11
by: Peter Oliphant | last post by:
I've been trying all morning to convert my 2003 project (managed) to 2005 (/clr since I have both managed and unmanaged code). I'm guessing I have tens of thousands of lines of code to change. Did...
5
by: feng | last post by:
OK, all I want is writting a string that represents an XML document into a file, say C:\test.xml. This kind of task used to be so easy with vb6. But now, with VB.Net, it seems turned into a big...
3
by: nasirmajor | last post by:
dear alls, i have a simple (not for me) quetion for c# or vb.net programmers. i want a user to give any number and a programme prints a fibonacci series for that number.thanks
13
by: ragtag99 | last post by:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch, comp.lang.c++ Im working with windows xp professional, NTFS and programming with MASM, c++ (free compiler) or visual basic 6.0...
10
by: kevinliu23 | last post by:
HI, I am new to Python and wanted to know how to check for the remaining disk space on my Windows machine using Python? I was thinking of using the command line "dir" and trying to extract the...
1
by: =?Utf-8?B?cGVsZWdrMQ==?= | last post by:
1)when i call to a Stored Procedure and for exampe i do : myCommand.Parameters.Add("@flag", Data.SqlDbType.Int) myCommand.Parameters("@flag").Value = DEAULT how can i pass a DEFAULT value tothe...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.