Procedure Or Function Has Too Many Argument Specified.
May 27, 2008
Hey, friends, i have a problem on my bank transaction page now: Procedure or function has too many argument specified.
people can log in by their usernames, 1 username can have many accounts, there are 2 account types:'c', 's'.
after people login, they are only allowed to withdraw money from their own account: here is some of my codes:
1 else if (DropDownList3.SelectedItem.Text == "withdraw")
2 {
3 SqlConnection sqlCon = new SqlConnection("Data Source=bandicoot.cs.rmit.edu.au;Initial Catalog=shuli;User ID=test;Password=test");
4 SqlCommand cmd = new SqlCommand("usp_withdraw", sqlCon);
5 string spResult = "";
6 cmd.CommandType = CommandType.StoredProcedure;
7 cmd.Parameters.Add("@username", SqlDbType.NVarChar).Value = Session["username"].ToString();
8 cmd.Parameters.Add("@AccountFrom", SqlDbType.VarChar).Value = TextBox3.Text;
9 cmd.Parameters.Add("@Amount", SqlDbType.Decimal).Value = TextBox5.Text;
10 cmd.CommandType = CommandType.StoredProcedure;
11 sqlCon.Open();
12 spResult = cmd.ExecuteScalar().ToString();
13 if (string.Compare(spResult, "Execute successfully") == 0)
14 {
15 SqlDataSource with = new SqlDataSource();
16 with.ConnectionString = ConfigurationManager.ConnectionStrings["shuliConnectionString"].ToString();
17
18 with.InsertCommand = "insert into Transactions(TransactionType,AccountNumber,DestAccount,Amount,Comment,ModifyDate) values ('W','" + TextBox3.Text + "','" + TextBox3.Text + "','" + TextBox5.Text + "','" + TextBox2.Text + "','" + DateTime.Now.ToLocalTime() + "')";
19 int inertRowNum = with.Insert();
20 Server.Transfer("~/deposit_withdraw_confirm.aspx");
21 }
22 else
23 {
24 Server.Transfer("~/deposit_withdraw_error.aspx");
25 }
26
here is my store procedure
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER Procedure [dbo].[usp_withdraw]
(
@AccountFrom Varchar(20),
@Amount Decimal(10,2)
)
As
DECLARE @ReturnMsg AS VARCHAR(20)
DECLARE @balance AS Decimal(10,2)
DECLARE @username AS nvarchar(50)
SELECT @balance = balance
FROM Account,Login
WHERE Account.CustomerID=Login.CustomerID AND Login.UserID= @username and
AccountNumber = @AccountFrom
IF (
SELECT AccountType
FROM Account, Login
Where Account.CustomerID=Login.CustomerID AND Login.UserID= @username and AccountNumber = @AccountFrom
) ='c'
BEGIN
BEGIN TRAN
IF (@balance - @Amount) > 199
BEGIN
UPDATE Account
SET balance= balance-@Amount
WHERE AccountNumber=@AccountFrom
And (balance - @Amount) > 199
SET @ReturnMsg = 'Execute successfully'
COMMIT TRAN
END
ELSE
BEGIN
SET @ReturnMsg = 'Execute with error'
ROLLBACK TRAN
END
SELECT @ReturnMsg
END
IF (
SELECT AccountType
FROM Account
Where AccountNumber = @AccountFrom
) ='s'
BEGIN
BEGIN TRAN
IF (@balance - @Amount) > 0
BEGIN
UPDATE Account
SET balance= balance-@Amount
WHERE AccountNumber=@AccountFrom
And (balance - @Amount) > 0
SET @ReturnMsg = 'Execute successfully'
COMMIT TRAN
END
ELSE
BEGIN
SET @ReturnMsg = 'Execute with error'
ROLLBACK TRAN
END
SELECT @ReturnMsg
END
I think the problem is in Line 7
cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = Session["username"].ToString();this is to get the current login user's uername.
View 4 Replies
ADVERTISEMENT
Jan 25, 2013
Where did i do wrong in conversion
original query
dateadd(hour, datediff(hour,CONVERT(VARCHAR(19),B.CreateDate,111 ),B.CreateDate)
I tried to use convert(varchar(50),Datediff,21)
Below is the exact code..
convert(varchar(50),dateadd(hour, datediff(hour,CONVERT(VARCHAR(19),B.CreateDate,111 ),B.CreateDate),21)
View 10 Replies
View Related
May 14, 2008
Hi There,
Could someone please tell me why I am getting the above error on this code:
select (replace
(replace
(replace
(replace (serviceType, 'null', ' ')
, '<values><value>', ' ')
, '</value><value>', ',')
, '</value></values>', ' '))
from credit
serviceType (text,null)
Thanks,
Rhonda
View 1 Replies
View Related
Apr 17, 2007
I have a table with over 11,000 records and I need to do a find and replace using SET and Where conditions. Basically I have one column in the table called RealAudioLink. It contains entries like: wkdy20070416-a.rm and wkdy20070416-b.rm and conv20070416.rm.
I need the select statement to find all wkdy entries and replace those characters with Weekday. I also need it to find all dashes and small a's and b's and replace with null or nothing. Then I need it to insert a capital letter A or B in the
wkdy20070416-a.rm filename so that when it's all said and done that entry would read:
WeekdayA20070416.rm
WeekdayB20070416.rm
Conversation20070416.rm
Here is the code I am working with. It needs help. I'm close but I'm not knowledgeable with using SET or with removing dashes and inserting capital letters all in the same select statement.
Code Snippet
UPDATE T_Programs_TestCopy
(SET RealAudioLink = REPLACE(RealAudioLink, '-a', '')
AND
(SET RealAudioLink = REPLACE(RealAudioLink, 'wkdy', 'WeekdayA')
WHERE (RealAudioLink LIKE 'wkdy%'))
I've never done anything like this before so I would be very appreciative of any assistance with the select statement. I am reading up on it but it would be great to get another perspective from a more experienced sql developer.
Thanks
View 1 Replies
View Related
Aug 19, 2007
Hi guys,
I am using the LIKE function combined with a CASE WHEN to change a long list of words, but the list is too long...
Is there any posibility to insert more than one argument into one like function...?
Any other good ideas?
Below an example of the code I am using..
Thanks in advance,
Aldo.
Code Snippet
Case
WHEN JurnalTrans.DESCRIPTION LIKE '%myArgument01%' THEN 'Result'
WHEN JurnalTrans.DESCRIPTION LIKE '%myArgument02%' THEN 'Result'
WHEN JurnalTrans.DESCRIPTION LIKE '%myArgument03%' THEN 'Result'
WHEN JurnalTrans.DESCRIPTION LIKE '%myArgument04%' THEN 'Result'
ELSE ''
END AS 'Result'
View 2 Replies
View Related
Mar 9, 2008
Hey Guys,
I'm having problems with my SQL statement and Im wondering if anyone could help? My code is below.
The Label6 is filled up using a previous SQL Statement, and when Ive had a fiddle around it is using the KnowledgeID It works in reading in the date, it just doesnt appear to want to work for the second statement as I am getting the error shown in the subject.
Thanks in advance =)
C# Codeprotected void Button2_Click(object sender, EventArgs e)
{KnowledgeID = Convert.ToInt32(Label5.Text);
string path = Server.MapPath(" ") + "\X_Drive\";FileLocation = path + Convert.ToString(FileUpload1.FileName);SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand myCommand2 = new SqlCommand("select * from Knowledge WHERE KnowledgeID = '" + KnowledgeID + "'", myConnection);
myConnection.Open();
SqlDataReader myReader = myCommand2.ExecuteReader();if (myReader.HasRows)
{while (myReader.Read())
{Add = myReader["DateAdded"].ToString();
}
myReader.Close();
}
else
{
myConnection.Close();
}
SqlTransaction trans = myConnection.BeginTransaction();
{
try
{
SqlCommand myCommand3 = new SqlCommand("Select ISNULL(MAX(Version,0)+1 FROM Archive WHERE KnowledgeID = "+KnowledgeID+"",myConnection);
myCommand3.Transaction=trans;int nextVersion =(int)myCommand3.ExecuteScalar();if (File != null)
{myCommand3 = new SqlCommand("INSERT INTO Archive (FixName, Description, Location, DateAdded, DateArchived, Version, KnowledgeID) SET (@FixName,@Description,@File,@Add,@AddDate,@SAPPS,@Version,'" + KnowledgeID + "')", myConnection);
}
else
{myCommand3 = new SqlCommand("INSERT INTO Archive (FixName, Description, DateAdded, DateArchived, Version, KnowledgeID) SET (@FixName,@Description,@Add,@AddDate,@SAPPS,@Version,'" + KnowledgeID + "')", myConnection);
}myCommand3.Parameters.AddWithValue("@FixName", TextBox1.Text);
myCommand3.Parameters.AddWithValue("@Description",TextBox2.Text);myCommand3.Parameters.AddWithValue("@File",FileLocation);
myCommand3.Parameters.AddWithValue("@Add",Add);myCommand3.Parameters.AddWithValue("@AddDate",AddDate);myCommand3.Parameters.AddWithValue("@Versions",nextVersion);
myCommand3.ExecuteNonQuery();
trans.Commit();
}catch (Exception ex)
{
//TextBox2.Text = ex.Message;
trans.Rollback();
myConnection.Close();
}
//}
View 5 Replies
View Related
Feb 11, 2008
Hello frend...i have a problem with my application when i'm trying to delete a certain data from gridview...i have a store procedure that already create in my mssql server...and in datasource i'm using command that i've already created in my mssql server...the problem is i dont know how i can send my value to the parameter in datasource.....and one more thing what is exaclty the error with 'Store procedure has <my function> too many argument" occur? Please help me....so i paste my code below to easier and detect my problem....(sorry my english are no good)....
1) This is my code in asp.net
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:SqlDataSource ID="SqlDSRole" runat="server" ConnectionString="<%$ ConnectionStrings:PVMCCon %>"
DeleteCommand="Roles_delete"
DeleteCommandType="StoredProcedure"
SelectCommand="Roles_view"
SelectCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="roleName" Type="String" />
</DeleteParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="Role_application_id"
DataSourceID="SqlDSRole" ForeColor="#333333" GridLines="None" PageSize="4">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField HeaderText="Role Application Id" Visible="False">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Role_application_id") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="roleApplicationIdLabel" runat="server" Text='<%# Eval("Role_application_id") %>'></asp:Label>
</EditItemTemplate>
<AlternatingItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Role_application_id") %>'></asp:Label>
</AlternatingItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Role Name" >
<ItemTemplate>
<asp:Label ID="roleName" runat="server" Text='<%# Eval("Role_name") %>' CssClass="LabelInfo" ></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="roleNameTxt" runat="server" Text='<%# Bind("Role_name") %>' Width="200px"></asp:TextBox>
</EditItemTemplate>
<AlternatingItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Eval("Role_name") %>' CssClass="LabelInfo"></asp:Label>
</AlternatingItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Role Description">
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Eval("Role_description") %>' CssClass="LabelInfo"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="roleDescriptionTxt" runat="server" Height="30px" Text='<%# Bind("Role_description") %>'
TextMode="MultiLine" Width="300px"></asp:TextBox>
</EditItemTemplate>
<AlternatingItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Eval("Role_description") %>' CssClass="LabelInfo"></asp:Label>
</AlternatingItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#E0E0E0" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
2) And this is my Store procedure that i created in mssql server
Store Procedure: Roles_view
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[Roles_view]
AS
BEGIN
SET NOCOUNT ON;
SELECT *
FROM Role
END
Store Procedure: Roles_delete
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[Roles_delete]
@roleName varchar(50)
AS
BEGIN
SET NOCOUNT ON;
DELETE FROM Role
WHERE Role_name LIKE @roleName
END
3) The problem is when i'm trying to delete my certain data, the message box appear and say "Procedure or function Roles_delete has too many argument specified".what should i do????anabosy please help me..
View 5 Replies
View Related
May 7, 2008
hai <br>
<p>i have a procedure where in which i want to access a specific table whose name will be passed into procedure as argument. Here is the peice of code i have made.</p>
CREATE PROCEDURE outputtable @tablename nchar(10) AS<br>
begin<br>
.........................<br>
insert into @tablename (classno) values (@cno)<br>
.................................<br>
END<br>
<p> I get the following error message :</p>
Msg 1087, Level 15, State 2, Procedure................<br>
Must declare the table variable "@tablename".<br>
<p>
Is there anyway i can get around this one. I will be grateful if anyone can help me</p>
View 5 Replies
View Related
Nov 7, 2007
Hello
I wonder if someone could suggest a way to obtain the following. Using SQL Server 2005 I want to create some stored procedures. I want to query the DB with various filter arguments and combinations of these. One way would be to create one stored procedure for each function signature. However, as the number of combinations of filter is large, if possible I'd rather have a generic input to the each stored procedure that corresponds to the entire WHERE clause' search condition.
The stereotype behavior I'm looking for is:
SELECT myField
FROM myTable
WHERE @mySearchCondition
Does any one have some good suggestion, code samples and/or links?
Kind regards
Jens Ivar
View 2 Replies
View Related
Feb 17, 2014
I have a stored procedure that ends with
Select columnname from tablename order by ordercolumn
We will call that "sp_foldersOfFile". It takes 1 parameter, a fileID (int) value.
The result when I execute this from within Management Studio is a single column of 1 to n rows. I want to use these values in another stored procedure like this:
Select @userCount = COUNT(*) from permissions where UserID = @userID and
(projectid = @projectID or projectid=0) and
clientid = @clientID and
folderpermissions in (dbo.sp_FoldersOfFile(@fileID))
The Stored Procedure compiles but it does not query the folderpermissions in the selected values from the sp_FoldersOfFile procedure. I'm sure it is a syntax issue.
View 9 Replies
View Related
Mar 25, 2007
I have an SqlDataSource control on my aspx page, this is connected to database by a built in procedure that returns a string dependent upon and ID passed in.
I have the followinbg codewhich is not complet, I woiuld appriciate any help to produce the correct code for the code file
Function GetCategoryName(ByVal ID As Integer) As String sdsCategoriesByID.SelectParameters("ID").Direction = Data.ParameterDirection.Input sdsCategoriesByID.SelectParameters.Item("ID").DefaultValue = 3 sdsCategoriesByID.Select() <<<< THIS LINE COMES UP WITH ERROR 1End Function
ERROR AS FOLLOWS
argument not specified for parameter 'arguments' of public function Select(arguments as System.Web.DatasourceSelect Arguments as Collections ienumerable
Help I have not got much more hair to loose
Thanks Steve
View 5 Replies
View Related
Sep 12, 2006
Hi everybody, I am having trouble how to fixed this code. I am trying to supply the parameterinside a stored procedure with a value, and displays error message shown below. If I did not supply the parameter with a value, it works. How to fix this?Error Message:Procedure or function <stored proc name> has too many arguments specified.Thanks,den2005
Stored procedure:
Alter PROCEDURE [dbo].[sp_GetIdeaByCategory]
@CatId <span class="kwd">int</span> = 0
AS
BEGIN
SET NOCOUNT ON;
Select I.*, C.*, U.* From Idea I inner join IdeaCategory C on I.CategoryID = C.IdeaCategoryID inner join Users U on I.UserID = U.UserID Where I.CategoryID = @CatId Order By LastModifiedDate Desc
End
oDataSource.ConnectionString = constr;
oDataSource.SelectCommand = storedProc;<span class="cmt">//storedproc - sp_GetIdeaByCategory</span>
oDataSource.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
oDataSource.SelectParameters.Add(<span class="st">"@CatId"</span>, catId);
gdvCategories.DataSourceID = oDataSource.ID;
gdvCategories.DataBind(); <<--- Error occured here
View 1 Replies
View Related
Jan 19, 2007
Can someone help me with this issue? I am trying to update a record using a sp. The db table has an identity column. I seem to have set up everything correctly for Gridview and SqlDataSource but have no clue where my additional, phanton arguments are being generated. If I specify a custom statement rather than the stored procedure in the Data Source configuration wizard I have no problem. But if I use a stored procedure I keep getting the error "Procedure or function <sp name> has too many arguments specified." But thing is, I didn't specify too many parameters, I specified exactly the number of parameters there are. I read through some posts and saw that the gridview datakey fields are automatically passed as parameters, but when I eliminate the ID parameter from the sp, from the SqlDataSource parameters list, or from both (ID is the datakey field for the gridview) and pray that .net somehow knows which record to update -- I still get the error. I'd like a simple solution, please, as I'm really new to this. What is wrong with this picture? Thank you very much for any light you can shed on this.
View 9 Replies
View Related
Feb 4, 2008
Can anybody know ,how can we add builtin functions(ROW_NUMBER()) of Sql Server 2005 into database library.
I get this error when i used into storeprocedure :
ROW_NUMBER() function is not recognized in store procedure.
i used MS SQL SERVER 2005 , so i think "ROW_FUNCTION()" is not in MS SQL SERVER 2005 database library.
I need to add that function into MS SQL SERVER 2005 database library.
Can anbody know how we can add that function into MS SQL SERVER 2005 database library?
View 4 Replies
View Related
Mar 26, 2007
Has anyone encountered this before?
Procedure or Function 'stored procedure name' expects parameter '@parameter', which was not supplied.
It seems that my code is not passing the parameter to the stored procedure.
When I click this hyperlink:
<asp:HyperLink
ID="HyperLink1"
Runat="server"
NavigateUrl='<%# "../Division.aspx?CountryID=" + Eval("CountryID")%>'
Text='<%# Eval("Name") %>'
ToolTip='<%# Eval("Description") %>'
CssClass='<%# Eval("CountryID").ToString() == Request.QueryString["CountryID"] ? "CountrySelected" : "CountryUnselected" %>'>
</asp:HyperLink>
it is suppose to get the country name and description, based on the country id.
I am passing the country id like this.
protected void Page_Load(object sender, EventArgs e)
{
PopulateControls();
}
private void PopulateControls()
{
string countryId = Request.QueryString["CountryID"];
if (countryId != null)
{
CountryDetails cd = DivisionAccess.GetCountryDetails(countryId);
divisionNameLabel.Text = cd.Name;
divisionDescriptionLabel.Text = cd.Description;
}
}
To my app code like this:
public struct CountryDetails
{
public string Name;
public string Description;
}
public static class DivisionAccess
{
static DivisionAccess()
public static DataTable GetCountry()
{
DbCommand comm = GenericDataAccess.CreateCommand();
comm.CommandText = "GetCountry";
return GenericDataAccess.ExecuteSelectCommand(comm);
}
public static CountryDetails GetCountryDetails(string cId)
{
DbCommand comm = GenericDataAccess.CreateCommand();
comm.CommandText = "GetCountryDetails";
DbParameter param = comm.CreateParameter();
param.ParameterName = "@CountryID";
param.Value = 2;
param.DbType = DbType.Int32;
comm.Parameters.Add(param);
DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
CountryDetails details = new CountryDetails();
if (table.Rows.Count > 0)
{
details.Name = table.Rows[0]["Name"].ToString();
details.Description = table.Rows[0]["Description"].ToString();
}
return details;
}
As you can see I have two stored procedures I am calling, one does not have a parameter and the other does. The getcountry stored procedure returns the list of countries in a menu that I can click to see the details of that country. That is where my problem is when I click the country name I get
Procedure or Function 'GetCountryDetails' expects parameter '@CountryID', which was not supplied
Someone please help!
Thanks Nickdel68
View 5 Replies
View Related
Apr 6, 2008
Hi,I'm working with visual studio 2008 and a sql server database. I'm also a bit of a beginner. I've written a stored procedure as below. My aim is to try and retrieve the data from field 'caption' through a paramater being passed.
I'm using the function as below to call this procedure through objectdatasource.
i'm getting the following error:
Compiler Error Message: BC30455: Argument not specified for parameter 'caption' of 'Public Sub New(id As Integer, count As Integer, caption As String, ispublic As Boolean)'.Source Error:
Line 98: Using reader As SqlDataReader = command.ExecuteReader()
Line 99: Do While (reader.Read())
Line 100: Dim temp2 As New Album(CStr(reader("Caption")))
Line 101: list2.Add(temp2)
Line 102: Loop
Any help will be apreciated, a lot of my code is copy and pasted and i don't fully understand every line which is where i assume the error is being made!
Thanks
FUNCTIONSPublic Shared Function GetAlbumName(ByVal AlbumID As Integer) As Generic.List(Of Album)
Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings("Personal").ConnectionString)Using command As New SqlCommand("GetAlbumName", connection)
command.CommandType = CommandType.StoredProcedurecommand.Parameters.Add(New SqlParameter("@AlbumID", AlbumID))
connection.Open()Dim list2 As New Generic.List(Of Album)()
Using reader As SqlDataReader = command.ExecuteReader()Do While (reader.Read())Dim temp2 As New Album(CInt(reader("AlbumID")), CStr(reader("Caption")))
list2.Add(temp2)
Loop
End UsingReturn list2
End Using
End Using
End Function
SQL STORED PROCEDURE
ALTER PROCEDURE GetAlbumName@AlbumID int
AS
SELECT
*FROM [Albums]WHERE [Albums].[AlbumID] = @AlbumID
RETURN
View 2 Replies
View Related
Apr 8, 2008
I try to replace the following statement : CmdPuzzle.Parameters.Append CmdPuzzle.CreateParameter("@Length",adTinyInt,adParamInput,,6)
with:
Dim retLengthParam As New SqlParameter("@Length", SqlDbType.TinyInt, , 6)
it highlighted the retLengthParam saying:
Argument not specified for parameter 'size' of 'Public Sub New(parameterName As String, dbType As System.Data.SqlDbType, size As Integer, sourceColumn As String)
Logic:
set that the input is only allowed 6 integer.
View 3 Replies
View Related
Jan 24, 2007
CREATE PROCEDURE sp_getT
@m1 int ,
@txn int ,
@Pan varchar(50) ,
@Act varchar(50) OUTPUT,
@Bal Decimal(19,4) OUTPUT,
@CBal Decimal(19,4) OUTPUT
AS
declare @pBal money, @pCbal money, @pAct money
SET NOCOUNT ON
IF @m1 = 200
BEGIN
IF @txn = 31
BEGIN
exec ChkBal @Pan, @pBal output, @pCbal output, @pAct out
END
END
SET @Act = @pAct
SET @Bal = cast(@pBal as Decimal(19,4))
SET @CBal = cast(@pCBal as Decimal(19,4))
return @Act
return @Bal
return @CBal
the above code returns this error message
"Server: Msg 8144, Level 16, State 2, Procedure CheckBalance, Line 0
Procedure or function ChkBal has too many arguments specified."
How do i specify all the arguments i want in the called procedure?
View 14 Replies
View Related
Jan 27, 2004
Is it possible to define an argument as optional for a UDF? I have a financial calculation that may or may not require a defined date range depending on the status of an individual item. Is there a way to avoid requiring the date range where it's not necessary?
View 10 Replies
View Related
Oct 8, 2007
Hi, nice to meet you all. I need to return a parameter value from a store procedure, i already done insert(), update(), delete() to return parameter back. Just only select() can't return parameter and it need argument, I try to write in Sqldatasource1.Select(Argument.empty), it can't work and return null. How should i solve the problem? Or I wirte the wrong argument? Can anyone help me? Thank in advance.
View 5 Replies
View Related
Apr 14, 2008
Hi i get the above error whenever i try and run my page, what i am trying to do is embed a repeater within a datalist, here is my code;public void Page_Load(object sender, EventArgs e)
{string strID = Request.QueryString["id"];
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["streamConnectionString"].ConnectionString);SqlCommand command = new SqlCommand("stream_Users", conn);
command.CommandType = CommandType.StoredProcedure;command.Parameters.Add("@userID", SqlDbType.Int).Value = Request.QueryString["id"];
SqlDataAdapter cmd1 = new SqlDataAdapter(command);
//Create and fill the DataSet.DataSet ds = new DataSet();
cmd1.Fill(ds, "userName");
//Create a second DataAdapter for the Titles table.SqlDataAdapter cmd2 = new SqlDataAdapter("select * from UserSpecialties", conn);
cmd2.Fill(ds, "specialty");
//Create the relation bewtween the Authors and Titles tables.ds.Relations.Add("myrelation",
ds.Tables["userName"].Columns["userID"],ds.Tables["specialtyName"].Columns["userID"]);
//Bind the Authors table to the parent Repeater control, and call DataBind.DataList1.DataSource = ds.Tables["userName"];
Page.DataBind();
//Close the connection.
conn.Close();
}
View 2 Replies
View Related
Nov 18, 2004
hello, I am doing some tutorials to learn SQL reporting services. One of the tutorials is using asp to call a web services and blah blah etc...
Basically the report opens with two calenders and an execute button. the user would pick two dates and then hit execute.
the code is this:
Private Sub cmdExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExecute.Click
Dim report As Byte() = Nothing
'Create an instance of the Reporting Services
'Web Reference
Dim rs As localhost.ReportingService = New localhost.ReportingService
'Create the credentials that will be used when accessing
'Reporting Services. This must be a logon that has rights
'to the Axelburg Invoice-Batch Number Report.
'***Replace "LoginName", "Password", and "Domain" with
'the appropriate values. ***
rs.Credentials = New _
System.Net.NetworkCredential("Administrator", _
"password", "localhost")
rs.PreAuthenticate = True
'The Reporting Services virtual path to the report.
Dim reportPath As String = _
"/Galactic Delivery Services/Axelburg/Invoice-Batch Number"
' The rendering format for the report.
Dim format As String = "html4.0"
'The devInfo string tells the report viewer
'how to display with the report.
Dim devInfo As String = _
"<DeviceInfo>" + _
"<Toolbar>False</Toolbar>" + _
"<Parameters>False</Parameters>" + _
"<DocMap>True</DocMap>" + _
"<Zoom>100</Zoom>" + _
"</DeviceInfo>"
'Create an array of the values for the report parameters
Dim parameters(1) As localhost.ParameterValue
Dim paramValue As localhost.ParameterValue _
= New localhost.ParameterValue
paramValue.Name = "StartDate"
paramValue.Value = calStartDate.SelectedDate
parameters(0) = paramValue
paramValue = New localhost.ParameterValue
paramValue.Name = "EndDate"
paramValue.Value = calEndDate.SelectedDate
parameters(1) = paramValue
'Create variables for the remainder of the parameters
Dim historyID As String = Nothing
Dim Credentials() As localhost.DataSourceCredentials = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String
Dim mimeType As String
Dim warnings() As localhost.Warning = Nothing
Dim reportHistoryParameters() As _
localhost.ParameterValue = Nothing
Dim StreamIDs() As String = Nothing
Dim sh As localhost.SessionHeader = _
New localhost.SessionHeader
rs.SessionHeaderValue = sh
Try
'Execute the report.
report = rs.Render(reportPath, format, historyID, _
showHideToggle, encoding, mimeType, _
reportHistoryParameters, warnings, _
StreamIDs)
sh.SessionId = rs.SessionHeaderValue.SessionId
'Flush any pending responce.
Response.Clear()
'Set the Http headers for a PDF responce.
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response().ClearContent()
HttpContext.Current.Response.ContentType = "text/html"
' filename is the default filename displayed
'if the user does a save as.
HttpContext.Current.Response.AppendHeader( _
"Content-Disposition", _
"filename=""Invoice-BatchNumber.HTM""")
'Send he byte array containing the report
'as a binary response.
HttpContext.Current.Response.BinaryWrite(report)
HttpContext.Current.Response.End()
Catch ex As Exception
If ex.Message <> "Thread was being aborted." Then
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "text/html"
HttpContext.Current.Response.Write( _
"<HTML><BODY><H1>Error</H1><br><br>" & _
ex.Message & "</BODY></HTML>")
HttpContext.Current.Response.End()
End If
End Try
End Sub
End Class
This is the area underlined as failing:
report = rs.Render(reportPath, format, historyID, _
showHideToggle, encoding, mimeType, _
reportHistoryParameters, warnings, _
StreamIDs)
The errors all pretty much go like this:
c:inetpubwwwrootAxelburgFrontEndReportFrontEnd.aspx.vb(95): Argument not specified for parameter 'ParametersUsed' of 'Public Function Render(Report As String, Format As String, HistoryID As String, DeviceInfo As String, Parameters() As localhost.ParameterValue, Credentials() As localhost.DataSourceCredentials, ShowHideToggle As String, ByRef Encoding As String, ByRef MimeType As String, ByRef ParametersUsed() As localhost.ParameterValue, ByRef Warnings() As localhost.Warning, ByRef StreamIds() As String) As Byte()'.
I searched around, but didn't really understand what these errors mean. Any help is greatly appreciated.
View 1 Replies
View Related
Jan 16, 2005
I am trying to extract a value out of a cookie and then use that as a parameter to a SQL Select...Where function but I am getting the Argument not specified for parameter error. I assume the value from the cookie is not in the variable that I created but I could be wrong.
What is the proper method for populating a variable from a cookie and using that value as part of a SQL Select....Where function?
After I get a value out of the Select...Where function, I need to use the dataset results in a DropDownList as well as perform the DataBind().
here's some of the code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
if Not Page.IsPostBack then
dim Code as String
Code = Server.HtmlEncode(Request.Cookies("UCodeCookie")("Code"))
label1.Text = Code
GetPropertyCodes(Code)
ddlPropertyCode.DataBind()
end if
End Sub
Function GetPropertyCodes(ByVal Code As String) As System.Data.DataSet
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='master'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [Property_Details_db].[Prop_Code] FROM [Property_Details_db] WHERE ([Property_Details_db].[Code] = @Code)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_code As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_code.ParameterName = "@Code"
dbParam_code.Value = Code
dbParam_code.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_code)
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Thanks for your help.
Chris
View 13 Replies
View Related
Feb 5, 2008
Trying to get a handle on how to attack this problem of adding a new record in a table that has 2 joins to access (user) and associate with a grandparent table (hotel).
There is also a date condition with a separate table (contracts) in order to start the operation.
Select from Contracts where TermBegin and TermEnd <> today
For each contract hotel{
#Do they already have user?
Match User.ID + Organization.ID + Hotel.ID
If not{
Create Person
}
I'm not sure how to return the negative results of the 3 table join of User.Id + Organization.ID + Hotel.Id
Thanks for any tips/iedas
View 5 Replies
View Related
Feb 8, 2002
The following vbscript executes the specified package,
however, I need to pass the package some arguments and
don't know how.
Set oPackageToExecute = CreateObject("DTS.Package")
oPackageToExecute.LoadFromSQLServer "SQLSERVER", , , TSSQLStgFlag_UseTrustedConnection, , , , "Package Name"
oPackageToExecute.Execute
oPackageToExecute.Uninitialize()
Set oPackageToExecute = Nothing
Any help is greatly appreciated,
Martin
View 5 Replies
View Related
Mar 16, 2007
I have to build a coherent argument for why we should fix the application to run at compt level 90 instead of just leaving it at 80.
Looking at . . .
Differences Between Lower Compatibility Levels and Level 90
http://msdn2.microsoft.com/en-us/library/ms178653.aspx
. . . I can't find anything further that tells my why it is in our best interest to do so other than 'Microsoft won't help you until you do'.
Anyone have any good bullet points on this?
View 6 Replies
View Related
Jul 20, 2005
I have ...CREATE PROC InvoiceDeleteExample2(@InvoiceList1 VARCHAR(255),@InvoiceList2 VARCHAR(255) = '',...@InvoiceListN VARCHAR(255) = '')AS....GOI would like....CREATE PROC InvoiceDeleteExample2(SELECT * FROM table;)AS....GOI hope help... thx
View 1 Replies
View Related
Oct 3, 2006
Is it possible to write custom code that achieves the same thing as an aggregate function?
ex: Calculating the sum of a group? (with out using the sum( field!one.value) function)
if I had a group that grouped on name.
Name Number
header Fields!FirstName.Value ************
details Fields!Number.Value
footer
Can i write a custom code function (or functions) that will get the sume of the numbers in that group.
Thanks in advance.
View 7 Replies
View Related
Aug 14, 2007
I have a stored procedure which accepts 3 arguments that are used in the WHERE clause of a SELECT Statement
CREATE PROCEDURE [dbo].[MyProcedure] @argYear INT, @argMonth INT, @argDay INT
AS
SELECT *
FROM MyData
WHERE
MyData.Year = @argYear AND MyData.Month = @argMonth AND MyData.Day = @argDay
The problem that I am having is @argDay is an "optional" argument. If @argDay is NULL then I want to basically ignore the "AND MyData.Day = @argDay" condition.
Is there an easier way to do this than:
IF @argDay is NULL
SELECT *
FROM MyData
WHERE
MyData.Year = @argYear AND MyData.Month = @argMonthELSE
SELECT *
FROM MyData
WHERE
MyData.Year = @argYear AND MyData.Month = @argMonth AND MyData.Day = @argDay
END IF
Thanks
View 7 Replies
View Related
Feb 2, 2007
Im getting this error when looping through a gridview. Im trying to save each row into the database. The weird thing is that it saves the first row, but errors out on the second.If I only add one item to the gridview, it works. The second row is screwing it up somehow. Any ideas? ------------------------------------------------------------------------------------------------------------------------------------------------------------------Some of my code to get an idea of how im doing it:(This
is for a shopping cart. It displays the products in the shopping cart.
If the order is approved by the CC processing company, each product
entry is saved in the DB. The gridview is being populated by my
ShoppingCart Profile Object.) SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["rdevie"].ConnectionString);
SqlCommand objCmd = new SqlCommand("InsertOrderDetails", objConn);
objCmd.CommandType = CommandType.StoredProcedure;
objConn.Open();
foreach (GridViewRow row in gvOrderDetails.Rows)
{
objCmd.Parameters.Add("@idOrder", SqlDbType.Int).Value = orderNum;
objCmd.Parameters.Add("@fldName", SqlDbType.NVarChar).Value = ((Label)row.FindControl("lblName")).Text;
objCmd.Parameters.Add("@fldUnitPrice", SqlDbType.Money).Value = ((Label)row.FindControl("lblUnitPrice")).Text;
objCmd.Parameters.Add("@fldQuantity", SqlDbType.Int).Value = Convert.ToInt32(((Label)row.FindControl("lblQuantity")).Text);
if (!String.IsNullOrEmpty(((Label)row.FindControl("lblSku")).Text))
objCmd.Parameters.Add("@fldSku", SqlDbType.NVarChar).Value = ((Label)row.FindControl("lblSku")).Text;
else
objCmd.Parameters.Add("@fldSku", SqlDbType.NVarChar).Value = DBNull.Value;
objCmd.Parameters.Add("@fldSize", SqlDbType.NVarChar).Value = ((Label)row.FindControl("lblSize")).Text;
objCmd.Parameters.Add("@fldLogo", SqlDbType.NVarChar).Value = ((Label)row.FindControl("lblLogo")).Text;
objCmd.Parameters.Add("@fldPlacement", SqlDbType.NVarChar).Value = ((Label)row.FindControl("lblPlacement")).Text;
objCmd.Parameters.Add("@fldColor", SqlDbType.NVarChar).Value = ((Label)row.FindControl("lblColor")).Text;
objCmd.ExecuteNonQuery();
}
objCmd.Dispose();
objConn.Close();
objConn.Dispose();
View 5 Replies
View Related
Oct 3, 2007
Hi,I have a simple stored procedure that basically SELECT some data from database. I am calling this stored procedure using a sqldatasource. The first time I try it, it works perfectly fine. But I get the error message "Procedure or function has too many arguments specified" the second time I try to search for thing. This is the code that I have that called the stored procedure: Session("SearchItem") = txtSearch.Text.Trim SqlDataSource1.SelectCommand = "_MyStoredProcedure" SqlDataSource1.SelectParameters.Add("SearchItem", Session("SearchItem")) SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure Gridview1.DataSourceID = "SqlDataSource1" Gridview1.DataBind() The following is the code in the stored procedure: CREATE PROCEDURE [dbo].[_MyStoredProcedure] ( @SearchItem nvarchar(255) = NULL)ASSELECT Field1, Field2, Field3 FROM Registration WHERE((@SearchItem IS NULL) OR (Field1 LIKE '%' + @SearchItem + '%') OR (Field2 LIKE '%' + @SearchItem + '%'))GO Please help.Stan
View 6 Replies
View Related
May 1, 2004
I know this is a stupid question (actually, maybe its not..?)
They seem to be identical in some ways, but not available to the outside world. what are some differences?
View 3 Replies
View Related
Jan 19, 2006
I have two tables: Person (member_no, name) and Participant (participant, member_no) member_no is the primary key in Person.The stored procedure is:CREATE PROCEDURE dbo.InsertRecs@member_no char(10),@name char(10),@participant char(10)ASbegininsert into person (member_no, name)values (@member_no, @name)select @member_no = @@Identityinsert into participant (participant, member_no)values (@participant, @member_no)endGOWhen I run this via the DetailsView control and try to insert a record I always get "Procedure or function InsertRecs has too many arguments specified"If I remove the second table from the stored procedure it works fine.Does anyone have any ideas?
View 9 Replies
View Related