Command.Parameters Collection Populated Automatically
Jan 31, 2007
Hi,
We have a lot of VB6 code that uses ADO 2.7 and stored procs wih Sql 2005. I have noticed recently that if I use the follow code:
Dim con As New ADODB.Connection
con.ConnectionString = "driver={SQL Server};server=(local);database=test;uid=sa;pwd="
con.Open
Dim com As New ADODB.Command
com.ActiveConnection = con
com.CommandText = "usp_GetSetting"
com.CommandType = adCmdStoredProc
com.Parameters.Append com.CreateParameter(...)
It will fail. the reason being the after setting the CommantText and Type ADO then seems to automatically go away and populate the Parameters collection from the databases metadata according to the SP we are calling.
I have never seen this before, I thought the Refresh method had to be called before the parameters collection get populated.
Can anyone help me please?
View 1 Replies
ADVERTISEMENT
Mar 12, 2008
Hi all,
From the "How to Call a Parameterized Stored Procedure by Using ADO.NET and Visual Basic.NET" in http://support.microsft.com/kb/308049, I copied the following code to a project "pubsTestProc1.vb" of my VB 2005 Express Windows Application:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlDbType
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim PubsConn As SqlConnection = New SqlConnection("Data Source=.SQLEXPRESS;integrated security=sspi;" & "initial Catalog=pubs;")
Dim testCMD As SqlCommand = New SqlCommand("TestProcedure", PubsConn)
testCMD.CommandType = CommandType.StoredProcedure
Dim RetValue As SqlParameter = testCMD.Parameters.Add("RetValue", SqlDbType.Int)
RetValue.Direction = ParameterDirection.ReturnValue
Dim auIDIN As SqlParameter = testCMD.Parameters.Add("@au_idIN", SqlDbType.VarChar, 11)
auIDIN.Direction = ParameterDirection.Input
Dim NumTitles As SqlParameter = testCMD.Parameters.Add("@numtitlesout", SqlDbType.Int)
NumTitles.Direction = ParameterDirection.Output
auIDIN.Value = "213-46-8915"
PubsConn.Open()
Dim myReader As SqlDataReader = testCMD.ExecuteReader()
Console.WriteLine("Book Titles for this Author:")
Do While myReader.Read
Console.WriteLine("{0}", myReader.GetString(2))
Loop
myReader.Close()
Console.WriteLine("Return Value: " & (RetValue.Value))
Console.WriteLine("Number of Records: " & (NumTitles.Value))
End Sub
End Class
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The original article uses the code statements in pink for the Console Applcation of VB.NET. I do not know how to print out the output of ("Book Titles for this Author:"), ("{0}", myReader.GetString(2)), ("Return Value: " & (RetValue.Value)) and ("Number of Records: " & (NumTitles.Value)) in the Windows Application Form1 of my VB 2005 Express. Please help and advise.
Thanks in advance,
Scott Chang
View 29 Replies
View Related
Mar 3, 2004
Hello,
I have a real heartache with runtime parameter interogation on my DB.
Sure I get the latest and greatest and sure I don't have to type in all those lovely parameter types..but...the hit I take on performance for making no less then 3 DB hits for each SqlAdapter is unreasonable!
So ...I like the idea of maybe calling it once for all my stored procs on application startup...and then maybe saving this in CacheObject.
My problem is that I can't see where you can even serialize a SqlParametersCollection or even for that matter assign it to a Command object. Can you cache a command object ?
LOL
I think I may just have to write some generic routine for creating and populating my command objects based on a key (type) and then use that to fetch my command.Update,
command.Insert and command.
I would like to use the new AsynchBlock to do the fetching of the stored proc parameters and then just pull them from the Cache object....put a file watch so that if the DB's change my params it re-pulls them again.
*nice*.....
Then I get the best of both worlds...caching...and no parameter writing...
Eric
View 4 Replies
View Related
Nov 15, 2006
Hello all,
I have a project where I need to automatically pass 2 sets of parameters to a SSRS report and generate PDF files. I have set the defaults for the parameters based on one set of parameters and created a subscription to automatically generate PDF copy. However, I am not sure how to generate the report automatically using the other set of parameters. Also, I don't want to create two report files to accomplish this.
Can you please help?
Thanks in advance,
Saurav
View 1 Replies
View Related
Dec 4, 2007
It seems that my report runs immediately now that I've set defaults on all parameters. Is there a way to allow defaults on all params but still require that the user click "view report" before it runs?
View 3 Replies
View Related
Dec 12, 2004
If i am using SqlCommand Class and the CommandType of it is Text, then will it add "sp_executesql N" in front of the sql command automatically in fact, just like SqlDataAdapter?
View 3 Replies
View Related
Apr 26, 2007
I have created a report, and am setting default values for the parameters. Once the default parameters is set, the report automatically generates. Is there a way to make it not automatically generate the report? We are setting the parameters with values that will get the end user the most recent data, but alot of times, they will want to pull older data as well. We don't want them to have to wait for the report to automatically generate before they can change the parameter values
View 1 Replies
View Related
Nov 10, 2006
If all the parameters for a report have default values, the report runs automatically as soon as you open it. Is there a way to prevent this?
View 9 Replies
View Related
Nov 26, 2007
hi there
I am using SQL Server 2005 with Reporting Services (Using the Visual side - not direct code)
I am having problems understanding the dates. eg where to put them,
I want a report that runs on the 1st day of the month for the previous month. I know you can set up something in subscriptions but then how do I get my report header to say from .......to...............
I have been through the AW reports but can't see what I need.
Happy if someone wants to direct me to somewhere that has date examples.
cheers
Dianne
View 5 Replies
View Related
Aug 18, 2015
I pull data from Sql Server through the query, I want to pass the region parameter to the power pivot connection query. So that I can automatically pull the required region data. The parameter should pick the value from the excel range. And also how to control this through VBA
View 4 Replies
View Related
May 19, 2008
hi,
this is sanjeev,
i have SSIS package, using my c# program i want to add one execute package task to this package's sequence container.
it is creating the new package with out any probelm. but when i opened the package and try to move the newly created exeute package task it is giving the following error.
the element cannot be found in a collection. this error happens when you try to retrieve an element from a collection on a container during the execution of the package
this is my code
{
Package pkg = new Package();
string str = (string)entry.Key;
pkg.Name = str;
alEntity = (ArrayList)entry.Value;
ConnectionManager conMgr;
Executable chPackage;
TaskHost executePackageTask;
Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
//string PackagePath = @"c:Genesis.dtsx";
//p = app.LoadPackage(PackagePath, null);
p = new Package();
p.LoadFromXML(parentPackageBody, null);
p.Name = str;
//Sequence seqContainer;
IDTSSequence seqContainer;
//seqContainer = (Sequence)p.Executables["Extract Genesis Data"];
seqContainer = ((Sequence)p.Executables[0]);
string packageLocation = @"Geneva Packages";
conMgr = p.Connections["SQLChildPackagesConnectionString"];
foreach (string val in alEntity)
{
if (seqContainer.Executables.Contains("Load_" + val) == false)
{
chPackage = seqContainer.Executables.Add("STOCK:ExecutePackageTask");
executePackageTask = (TaskHost)chPackage;
executePackageTask.Name = "Load_" + val;
executePackageTask.Description = "Execute Package Task";
executePackageTask.Properties["Connection"].SetValue(executePackageTask, conMgr.Name);
executePackageTask.Properties["PackageName"].SetValue(executePackageTask, packageLocation + ddlApplication.SelectedItem.Text + @"" + executePackageTask.Name);
}
}
app.SaveToXml(Server.MapPath("../SynchronizeScript/Packages/" + ddlApplication.SelectedItem.Text + @"") + str + ".dtsx", p, null);
}
please let me know what is the wrong in my code.
thanks in advance.
regards
sanjeev bolllina
sanjay.bollina@gmail.com
View 14 Replies
View Related
Sep 6, 2006
Hi all, I'm having some trouble using the SQL IN command when using a parameter that contains the IN data.For example, without using parameters, I could do:select * from assetsmaster where extension in ('doc','vsd')But I would like to do it this way:select * from assetsmaster where extension in (@strFile)My stored procedure would look similar to this:GOCREATE PROC dbo.GetAssetList2( @xmlFileList varchar(1000), @strContainsClause varchar(1000), @strFileTypes varchar(1000))ASBEGIN SET NOCOUNT ON DECLARE @intDocHandle int EXEC sp_xml_preparedocument @intDocHandle OUTPUT, @xmlFileList SELECT DISTINCT AssetsMaster.AssetMasterUID, AssetsMaster.AssetFileName FROM AssetsMaster WHERE AssetsMaster.Extension IN (@strFileTypes)What format does the parameter need to be in? I can't execute the procedure like this, as it tries to parse the parameter before executing, I think:USE [GTGAssets]GODECLARE @return_value intEXEC @return_value = [dbo].[GetAssetList2] @xmlFileList = N'<NewDataSet...Table></NewDataSet>', @strContainsClause = N'soa', @strFileTypes = N'''DOC'',''VSD'',''BMP''' <<<Those are all single quotesSELECT 'Return Value' = @return_valueGOSo my problem is, how does the parameter get passed so I can test it?Thanks!James
View 1 Replies
View Related
Jan 17, 2007
Hello!
Is there a way to use an OLE DB Command transform to execute the following SQL query?
"Select sum(length(" + @[User::varDBName] + ":informix.cyh_t.u_obj)) from " + @[User::varDBName] + ":informix.cyh_t, " + @[User::varDBName] + ":informix.cch_t
where " +
@[User::varDBName] + ":informix.cch_t.d_obj = {D '" + @[User::strQueryDate] + "'} and " +
@[User::varDBName] + ":informix.cch_t.n_objid = " + @[User::varDBName] + ":informix.cyh_t.n_objid"
I get a DB number from an OLE DB Source, do a lookup to get the DB name and then I want to use the OLE DB command to get a result from the query but I can't seem to get this to work. Am I using the wrong transform?
Thanks.
View 4 Replies
View Related
Oct 10, 2006
Im looking for example code to make a sql update... I want to use command.Parameters and variables from text boxes and i'm unsure how to do this... Please help. This code below doesn't work but it is an example of what i've been working with.. <code> { string conn = string.Empty; ConnectionStringsSection connectionStringsSection = WebConfigurationManager.GetSection("connectionStrings") as ConnectionStringsSection; if (connectionStringsSection != null) { ConnectionStringSettingsCollection connectStrings = connectionStringsSection.ConnectionStrings; ConnectionStringSettings connString = connectStrings["whowantsConnectionString"]; conn = connString.ConnectionString; using (SqlConnection connection = new SqlConnection(conn)) using (SqlCommand command = new SqlCommand("UPDATE users SET currentscore=5)", connection)) { updateCommand.Parameters.Add("@currentscore", SQLServerDbType.numeric, 18, "currentscore"); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } } }</code>
View 3 Replies
View Related
Mar 5, 2008
Hi All,
I have an sql command which has subqueries in it. I need to pass in variables like startdate and enddate to the sub query query and then execute the query. What is the best way to do this?
I am trying to use ole db source but this has a limitation of not allowing parameters at the sub query level. What else can I use? I am working with sql server 2005.
Thanks a lot.
View 6 Replies
View Related
Apr 22, 2008
Hi all,
A quick newbie question...
I am trying to install SQL Server 2005 Standard and upgrade from Express edition. The Edition Change check tells me I must run the setup from the command prompt "and include the SKUUPGRADE=1 parameter", but I don't know how to enter this from the command line.
I've tried "D:setup SKUUPGRADE=1" and "D:setup -SKUUPGRADE=1", as well as "D:setup.exe /SKUUPGRADE=1" without success.
Can anyone give me a clue as to where I'm going wrong?
Thanks in advance.
Slammin!
View 3 Replies
View Related
Apr 25, 2007
I am trying to use the OLE DB Command component in a data flow. I setup the connection manager and then entered the following SQL command.
UPDATE FCustomer
SET FId = CASE
WHEN ISNULL(@p1, 'N') = 'Y' AND @p2 IS NULL THEN '2'
ELSE '3' END
WHERE Id = @p3
AND CustomerId = @p4
So after that I went to the parameter tab and tried to set the data types. I assigned the data types. Mapped the fields to the paramters and hit ok. Ran the package and failed with a cast/conversion issue. When i went back in the parameters are all set back to the Integer 8 data type. I change, go back in and reset again. The help file says I can change the parameter names and data types, which it allows me to do, but never saves the settings.
Am I doing something wrong? Is this not possible?
Thanks!
View 1 Replies
View Related
Aug 2, 2007
Hi,i try to update field 'name' (nvarchar(5) in sql server) of table 'mytable'.This happens in event DetailsView1_ItemUpdating with my own code.It works without parameters (i know, bad way) like this:SqlDataSource1.UpdateCommand = "UPDATE mytable set name= '" & na & "'"But when using parameters like here below, i get the error:"Input string was not in a correct format"Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdatingSqlDataSource1.UpdateCommand = "UPDATE mytable set name= @myname"SqlDataSource1.UpdateParameters.Add("@myname", SqlDbType.NVarChar, na)SqlDataSource1.Update()End SubI don't see what's wrong here.Thanks for helpTartuffe
View 4 Replies
View Related
Dec 26, 2007
I have an SQLDataSource. The SQL is
SELECT UserName, Category, ItemDescription, Size, Price, Reduce, Donate, Sold, ItemNumber, SoldDate, SoldPrice, PrintedFROM Tags WHERE (Printed = @Printed1 OR Printed = @Printed2 OR Printed = @Printed3) ORDER BY ItemNumber DESCThe bit field "printed" can be NULL, True or False.In the Selecting event of the SQLDataSource I have the following to show ALL records. But it does not work. If I remove these parameters it show ALL records.
e.Command.Parameters("@Printed1").Value = Nothing 'ASP.NET 2.0 using Visual basice.Command.Parameters("@Printed2").Value = Truee.Command.Parameters("@Printed3").Value = False
What am I doing wrong???
Thanks
Craig
View 10 Replies
View Related
May 12, 2008
SelectCommand="SELECT [id], [ref_id], [ref_name] FROM [ref] where [delete_flag] = 'N' AND [flag_transmit] = 'N' AND [ref_name] = @ref_name ">
<asp:ControlParameter Name="ref_name" ControlId="SrchRefName" PropertyName="Text" ConvertEmptyStringToNull="false"/>
The gridview of all the records is displayed on the page by default. There is a lookup of SSN and Name and putting values in those fields should filter the records and display only the row containing entered Name.I have trouble with the SelectCommand. No gridview is displayed with the above command even if value is entered in the Lookup textBox (SrchRefName).But when I change the selectcommand to- (using OR) SelectCommand="SELECT [id], [ref_id], [ref_name] FROM [ref] where [delete_flag] = 'N' AND [flag_transmit] = 'N' OR [ref_name] = @ref_name "> <asp:ControlParameter Name="ref_name" ControlId="SrchRefName" PropertyName="Text" ConvertEmptyStringToNull="false"/> the default gridview is displayed with all the records even though a value is entered in the lookup text box. Please help.
View 2 Replies
View Related
May 21, 2002
Hi all,
Are there any parameters for the SQLMANGR program???
I need to start it from the install script, and
have it autostart....
I found a single parameter /n that starts
the program without any display -
But I need it to autostart the server service itself,
so i can do some osql stuff after the installtion is completed.
thanks
tony
View 1 Replies
View Related
Jul 20, 2005
I want to run and 'Alter Database' statement from within a batch file.The batch file is to be run from an external automation program,(don't ask why)..I know the syntax for the alter db statement but not sure how to do itin a batch file and also If I have 2 instances how do I run it againsteach instance.All being done on Windows 2000 with Sql 2000.Any ideas will be a help.
View 1 Replies
View Related
Sep 23, 2006
I have a package that let me to import data from a excel book to a Sql server data base. When I try to run this package like a step into a SQL server Job it show me the next error.
"The command line parameters are invalid. The step failed."
the "command line" looks like this
/FILE "C:ProjectPackage.dtsx" /CONNECTION ConexionExcel;"Provider=Microsoft.Jet.OLEDB.4.0;Da ta Source=;Extended Properties=""EXCEL 8.0;HDR=YES"";" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING EWCDI
and in my excel conexion is:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=;Extended Properties="EXCEL 8.0;HDR=YES";
When i run the "Command Line" in the "Command window" the error is more expecific
"EXCEL 8.0;HDR=YES;" is not valid
So I chanded the "Command Line" in order to run it in de command window(look the double quote in the excel properties)
/FILE "C:ProjectPackage.dtsx" /CONNECTION ConexionExcel;"Provider=Microsoft.Jet.OLEDB.4.0;Da ta Source=;Extended Properties="EXCEL 8.0;HDR=YES";" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING EWCDI
then the package RUN, but when i tried to do the same thing in the
sql wizzard, it just dont work and it lost the threat from de package and the errors says this time:
Couldn't find the package
Some one who knows the answer or has any idea to helpme please?
thanks
View 5 Replies
View Related
Sep 26, 2006
Hi all,
is it good practice to remove SQL Parameters from the Command Object's parameters collection after the CommandObject has executed its SQL containing the SQL Parameters?
The reason I ask is because I have encountered some issues (errors) stating that the SQL Parameter cant be used because it is still contained in another Parameter collection - ( I created the Parameters, and then use these same parameter (through looping) to execute new commands).
Thanks
View 3 Replies
View Related
Jan 9, 2007
Hi there,
In order to prevent lookup errors in a lookup transformation, I've decided to go for an OleDb Command Transformation.
This transformation should check the lookup and, if it turns out to be null, ir returns a dummy value. Otherwise, it would return the lookup value.
This should be done by doing something like this:
select coalesce( (select ID_Table2 from ID_Table2 where FK_Table1 = ?), 0)
suposing Table2 has an atribute called "FK_Table1" that should match a column in the data flow.
Now, such command result in this message:
"An OLE DB record is available. Source "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Syntax eror, permission violation, or other nonspecific error".
But, it I remove the coalesce and type the following command:
select ID_Table2 from ID_Table2 where FK_Table1 = ?
It presents me no errors and allows me to continue.
Did i did anything wrong or is this something that is not possible to be done?
I know i have the option to use a script task to do this operation, but that would turn the maintenance process a little more difficult.
Otherwise, i know i could also re-direct the error from the lookup transformation and handle it. Though, my package has about 10 lookups and that would turn my package a lot more complex than
Thanks in advance
Best Regards
André Santana
View 6 Replies
View Related
Dec 14, 2007
I have an update command with 7 parameters, but at run time the order to the parameters gets mixed up.
I'm using a stored procedure. At first I have the command type set to text, and was calling it using EXEC spName ?,?,?,?,?,?,?
I then named each of the parameters and set their sources. The parameters are like this (samepl name, then source, then type):
A : QueryString - intB: Control - intC: Control - intD: None - intE: None - decimalF: Control - datetimeG: Control - datetime
At run time I was getting an error that an integer couldn't be converted to date time. So I put a breakpoint in the Updating event and then looked at the parameters prior to update.
This is how they looked (Parameter index, paramter name):
[0] A[1] B[2] D[3] E[4] F[5] G[6] C
It didn't maek any sense. Do, I deleted all of the paramters and readded them. That didnt' work. Then I changed the command to StoredProcedure and refreshed the parameters from the stored proc and it brought them in the right order, but the problem remains the same.
I looked at the page source, and there are no indexes in the page source, but the parameters are listed in the proper creation order, as follows:<UpdateParameters><asp:QueryStringParameter Type="Int32" Name="PROJ_ID" QueryStringField="pid"></asp:QueryStringParameter><asp:ControlParameter PropertyName="SelectedValue" Type="Int32" Name="TASK_UID" ControlID="fvTask"></asp:ControlParameter><asp:ControlParameter PropertyName="SelectedValue" Type="Int32" Name="ASSN_UID" ControlID="gvResources"></asp:ControlParameter><asp:Parameter Type="Int32" Name="RES_UID"></asp:Parameter><asp:Parameter Type="Double" Name="Work"></asp:Parameter><asp:ControlParameter PropertyName="Text" Type="DateTime" Name="Start" ControlID="TASK_START_DATETextBox"></asp:ControlParameter><asp:ControlParameter PropertyName="Text" Type="DateTime" Name="Finish" ControlID="TASK_FINISH_DATETextBox"></asp:ControlParameter></UpdateParameters>
No mater what I do, at run time ASSN_UID is always the last parameter. I've also run a SQL trace to see how it is actually being executed, and sure enough, its passing the value for ASSN_UID as the last parameter, which obviously doesn't work.
Any ideas as to why this would happen or how to fix it?
(I guess I can reorder the patameters in the stored proc to match how they are being passed, but still, that wouldn't be a very comfortable solution, since it could perhaps revert at some point or something)
View 2 Replies
View Related
Feb 23, 2008
Hello all,I'm writing a site with one page that uses the session variable (User ID) to pick one user ID out of a comma separated list in the field Faculty. The default parameterized query designed in the SqlDataSource wizard only returns lines that contain an exact match:SELECT * FROM tStudents WHERE ([faculty] = @faculty) The query: SELECT * FROM tStudents WHERE ([faculty] LIKE '%userID%') works as I need when I hard code the query with a specific user ID into the SqlDataSource in the aspx page. It will not work if I leave the @faculty parameter in it:SELECT * FROM tStudents WHERE ([faculty] LIKE '%@faculty%') e.Command.Parameters works to replace the @Faculty with a user ID, but again, adding the single quote and percentage sign either causes errors or returns no results. I've tried several variations of: string strEraiderID = "'%" + Session["eRaiderID"].ToString() + "%'"; e.Command.Parameters["@faculty"].Value = strEraiderID;no results are returned, not even the lines returned with the default select query.How do generate the equivalent of SELECT * FROM tStudents WHERE ([faculty] LIKE '%userID%') into the SqlDataSource? Thanks much!
View 3 Replies
View Related
Dec 20, 2007
Hi,
When I execute a stored procedure from an OLE DB Command transformation, where the sp takes a parameter and RetainSameConnection=TRUE and DelayValidation=TRUE are set, I get the error
"Syntax error, permission violation, or other nonspecific error"
If I take out the param or set RetainSameConnection=FALSE on the connection, all is fine again?
Has anyone has come across this?
Cheers
View 3 Replies
View Related
Oct 31, 2007
I have a stored proc with 28 commmands but only 24 are loaded. If I move the parameters around the ones that didn't show are visible and the ones after the 24th parameter don't show up. Is there some sort of limit on parameters for OLEDB commands that execute stored procs in the exec procname @p = ? construct?
View 3 Replies
View Related
Sep 13, 2007
The question is in the title.
View 4 Replies
View Related
Aug 31, 2007
Hello all,
Ok, I finally got my SqlDataSource working with Oracle once I found out what Oracle was looking for. My next hurdle is to try and set the Update Command and Parameters dynamically from a variable or radiobutton list. What I'm trying to accomplish is creating a hardware database for our computers by querying WMI and sending the info to textboxes for insertion and updating. I got that part all working nicely. Now I want to send the Computer name info to a different table column depending on if it is a laptop or desktop. I have been tossing around 2 ideas. A radiobutton list to select what it is and change the SQL parameters or do it by computer name since we have a unique identifier as the first letter ("W" for workstation, "L" for Laptop). I'm not sure what would be easiest but I'm still stuck on how this can be done. I posted this same question in here a few days ago, but I didn't have my SqlDataSources setup like I do now, I was using Dreamweaver 8, it is now ported to VS 2005. Below is my code, in bold is what I think needs to be changed dynamically, basically i need to change DESKTOP to LAPTOP...Thanks for all the help I've gotten from this forum already, I'm very new to ASP.NET and I couldn't do this without all the help. Thanks again!
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CAT %>"ProviderName="<%$ ConnectionStrings:CAT.ProviderName %>" SelectCommand='SELECT * FROM "COMPUTER"' UpdateCommand="UPDATE COMPUTER SET DESKTOP = :DESKTOP, TECH = :TECH, SERVICE_TAG = :SERVICE_TAG WHERE USERNAME=:USERNAME">
<UpdateParameters>
<asp:ControlParameter Name="USERNAME" ControlId="txtUserName" PropertyName="Text"/>
<asp:ControlParameter Name="SERVICE_TAG" ControlId="txtServiceTag" PropertyName="Text"/>
<asp:ControlParameter Name="TECH" ControlId="txtTech" PropertyName="Text"/>
<asp:ControlParameter Name="DESKTOP" ControlId="txtComputerName" PropertyName="Text"/>
</UpdateParameters>
</asp:SqlDataSource>
View 1 Replies
View Related
Feb 21, 2004
Hi everybody, I would like to know if it's possible to execute a stored procedure, passing it parameters, using not CommandType.StoredProcedure value of sqlcommand, but CommandType.Text.
I tried to use this:
sqlCmd.CommandType = CommandType.Text
sqlCmd.Parameters.Add(sqlPar)
sqlCmd.ExecuteNonQuery()
With this sql command:
"exec sp ..."
I wasn't able to make it to work, and I don't know if it's possible.
Another question:
if it's not possible, how can I pass a Null value to stored procedure?
This code:
sqlPar = new SqlParameter("@id", SqlDbType.Int)
sqlPar.Direction = ParameterDirection.Output
cmd.Parameters.Add(sqlPar)
sqlPar = new SqlParameter("@parent_id", DBNull)
cmd.Parameters.Add(sqlPar)
doesn't work, 'cause I get this error:
BC30684: 'DBNull' is a type and cannot be used as an expression.
How can I solve this?
Bye and thanks in advance.
P.S. I would prefer first method to call a stored procedure ('cause I could call it with 'exec sp null' sql command, solving the other problem), but obviusly if it's possible...=)
Sorry for grammatical mistakes.
View 9 Replies
View Related
Jul 20, 2005
I need to execute xp_cmdshell in a trigger and pass a command lineparameter to the .exe programi.e. I have a .exe program c:program filessavedata.exeIn the trigger I have a parameter @Id bigintI need to pass the parameter @Id to savedata.exeIn the trigger, I am tryingEXEC master..xp_cmdshell 'cmd.exe /C "c:program filessavedata.exe "'+ CAST(@Id as varchar)BUT this does not work.Can someone please help me with how to do this?Thanks,db
View 1 Replies
View Related