Hello,
How do I pass variables to a command text.(C#)Becaus e of the quotes,it
seems that the values are not passed.
Thanks,
Mike 1 3843
Hi Mike,
are you using a stored procedure or creating dynamic sql? If you are
using a stored procedure and using SQL Srver you can do something like:
SqlCommand command = new SqlCommand();
command.Command Text = "myStoredProced ureName";
//set the connection object
command.Connect ion = objConn;
command.Command Type = System.Data.Com mandType.Stored Procedure;
//create parameter and add it to the command
SqlParameter param = new SqlParameter("@ UserName",
System.Data.Sql DbType.VarChar, 30);
command.Paramet ers.Add(param);
If you are writing dynamic SQL then you could do something like:
string sqlCommand = "Select * from tblX WHERE UserName='" + userName + "'"
SqlCommand command = new SqlCommand(sqlC ommand, objConn);
Hope that helps
Mark R Dawson
"Mike" wrote: Hello, How do I pass variables to a command text.(C#)Becaus e of the quotes,it seems that the values are not passed. Thanks, Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: lawrence |
last post by:
Those of you with backgrounds with the C language will laugh at my
mistake, but those of you, like myself, who deal mostly with PHP
should be warned about passing variables as references - debugging
then requires a whole new mindset. I've a cms written in procedural
style that I've been converting to OOP. It is important to always pass
objects by reference. Unthinkingly, writing the constructors, I also
passed my config array by reference....
|
by: Matthew Robinson |
last post by:
i read a tutorial the other day on passing variables between php pages
using a html form and setting the action to the php page to parse, can
anybody see anything wrong with the code below? the problem is, that the
page always loads the html form, and i cant work out why this is so, even
after i select a catagory from the drop down list and press search. any1
have any idea's? TIA.
the code:
if (empty($catagory)) { ?>
|
by: Chieko Kuroda |
last post by:
Hello all,
I would like to learn the syntax for passing variables that I retreived from
a database to a second asp page. Currently, I'm using:
Response.Write "<tr><td> </td><td><Font size= ""-1""><B><a href=
""InterviewerInfo2.asp?timeID=" & rs("Starttime") & " "">"
How do I add more variables to my link: <a href = ...?
ie Nameofcandidate and InterviewDate
in this context:
|
by: Consuelo Guenther |
last post by:
Hello,
I am having problems with passing variables between pages. I have the
following:
First asp page has the function:
-----------------------------------------------------------------------
<script language="JavaScript">
function addProcess(addPName,addSProcess,addPIndex)
{
var addProcessWindow =
window.open('second.asp','mywindow','width=400,height=200');
|
by: Khai |
last post by:
First off, yes, I understand the crapload of tutorials out there, (well,
rather, I understand there /are/ a crapload of tutorials out there), the
problem is my comprehension.
I'm trying to pass variables, and can do so just fine with a URL, and $_GET.
What I would like to learn, and be very adept at using is the Form functions
and how you pass through that.
The problem in my comprehending this, is how does the original page know how...
| |
by: jsdeveloper |
last post by:
Hi,
I just started programming in javascript, and I'm having a problem passing variables between javascript and asp code in .asp page. Can you please help?
I've given the sample code below.
----------------------------------------------------------------------------------
<script src="http://www.aurumtech.com/domain_str.js"
type="text/javascript"></script> <script type="text/javascript">
var email_str = "joe@example.com"
var...
|
by: satterfieldben |
last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would call that variable in another Java script.
Sample script
<SCRIPT LANGUAGE="JavaScript">
function GetSelectedItem() {
len = document.formname.selectname.length
i = 0
chosen = "none"
|
by: coool |
last post by:
Hi :)
anyone knows how can I send variables from a php page to a form - i need to fill the form with these variables ?
maybe using (the process of passing variables to other pages - through url)
but how can i assign them to form variables ?
|
by: BezerkRogue |
last post by:
This is the most fundamental action I am sure, but I can't seem to make it happen.
I am familiar with passing variables in ASP. But that doesn't seem to be the preferred method in .NET. I have some scripts that run at the server for the form so I can't disable that statement. I followed Microsoft's instructions(I know..not the best thing to do) but still can't get the variables to pass.
I created a class and set up an @reference...
|
by: James |
last post by:
Hello,
I am able to get the result set when I am giving a hardcoded value
( Ex: "WHERE LIKE 'B%' ") in a command text, but when I am trying to
give a parameter to that and passing a value, I am not able to get the
result set.
Ex: cmdObj.Text= "SELECT Phone FROM Person.Contact WHERE LastName
LIKE '@filter%' ";
SqlParameter param = new SqlParameter(");
cmdObj.Parameters.Add(param);
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |