MSQL Views And Arguments
Jul 26, 2004
Greetings everyone.
A couple days ago, i posted a question on the Access boards.Here (http://forums.databasejournal.com/showthread.php?s=&threadid=36511)
Long story short, instead of filtering the results Locally, returned by query run locally on linked tables in an access front end, seems we should filter remotly. Seems easier and more secure.
We still want to hand out MS Access front ends. The results of queries run by users must be filtered based on authetication and values in the tables they query. There would be two ways to accomplish this.
1 - Stored procedures, apprearing as queries in Access.
2 - Views, appearing as tables.
Stored procedures are sure to work, but somewhat a hassle, sine we have to write code for each.
Views seem to be the simplest approach. we only need to build an SQL statement representing the new table. yet again, we have not done any constructive filtering. Is there a way to pass arguments to views just like stored procedures?
An exemple could be :
SELECT field1, field2, field3 FROM edu_details WHERE ID_department = @usr_dept AND ID_Division = $usr_div
usr_dept and usr_div being fields in the queried table(or course) AND auth information.
Cheers,
Lawrence
View 1 Replies
ADVERTISEMENT
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
May 11, 2004
Hi
Can anyone help me with the MSSQL following problem:
I want to update the field "Date" with today´s date in a Tabel named Customers
I want to click on a "button" that runs something like:
Update Date with Today´s date where CustomerName = TextBox.text
Thanks in advance for your help
View 1 Replies
View Related
Nov 16, 2006
Hi,
1. I am wondering if exist a tool to let me easily document my databases, unde MSQL.
e.g.I want to create a doc file or better a html file with all my databases objects, descriptions, DDLs etc...
2. Another tool to create code patterns; I need a something that generate custom code patterns, but in VBScript or C#.
p.s. Sorry if i created this topic on another forum.
Thanks,
<u><b>Jack Bower</b></u>
software developer
IATAR Studio
http://iatar.port5.com
View 13 Replies
View Related
Dec 17, 2007
Hello friends,
i am newly installed my client server from there i suppose to access the application.... when i clicked on the application icon it showing he following message:
Please note down the Error and Call EDP!!!!
Error number->[-2147467259]
Error Text->[[DBNETLIB][ConnectionOpen(Connect()),]SQL Server does not exit or access denied,]
am getting the above error..... can any one through your view plz.........
ENV: windows 2003 small business server, MSSQL (server)
windowsXP (client)
its working fine with all other client mechines.........
View 1 Replies
View Related
Jun 4, 2007
Hi All
My SQL is extremly rusted so I need some help with a very basic function. I have a character field which is built up using a category code + '-' + number. The problem I have is that the category codes are all different lengths and the items were added using 9 instead of 09. I'm trying to clean up the data so that the same item with e.g. category code DZ20 cannot be added as DZ20-1 and DZ20-01. How do I find the position of the '-' in the Query Analyser for MSSQL 2000?
View 1 Replies
View Related
Jul 20, 2005
Hi All,I want to use MS sql server edition 2000. I have installed the server. Now iwant to create the database on this server with tables and triggers. Canplease someone suggest me how to do this ?Thanks a lot,Dinesh
View 1 Replies
View Related
Aug 10, 2005
hello all during the instaletion i get an error message that SQL server can not start the service, after that the programm rolls instalation back.do someone knows what's going on?i use win xp pro.thank u for ur help.
View 2 Replies
View Related
Apr 3, 2006
Fellow database developers,I would like to draw on your experience with views. I have a databasethat includes many views. Sometimes, views contains other views, andthose views in turn may contain views. In fact, I have some views inmy database that are a product of nested views of up to 6 levels deep!The reason we did this was.1. Object-oriented in nature. Makes it easy to work with them.2. Changing an underlying view (adding new fields, removing etc),automatically the higher up views inherit this new information. Thismake maintenance very easy.3. These nested views are only ever used for the reporting side of ourapplication, not for the day-to-day database use by the application.We use Crystal Reports and Crystal is smart enough (can't believe Ijust said that about Crystal) to only pull back the fields that arebeing accessed by the report. In other words, Crystal will issue aSelect field1, field2, field3 from ReportingView Where .... eventhough "ReportingView" contains a long list of fields.Problems I can see.1. Parent views generally use "Select * From childview". This meansthat we have to execute a "sp_refreshview" command against all viewswhenever child views are altered.2. Parent views return a lot of information that isn't necessarilyused.3. Makes it harder to track down exactly where the information iscoming from. You have to drill right through to the child view to seethe raw table joins etc.Does anyone have any comments on this database design? I would love tohear your opinions and tales from the trenches.Best regards,Rod.
View 15 Replies
View Related
Sep 6, 2007
Which is more efficient? One large view that joins >=10 tables, or a few smaller views that join only the tables needed for individual pages?
View 1 Replies
View Related
Mar 3, 2006
Hi,I'm trying to store values from a session to sql server table. I created an sql stored procedure to pass the values into the database. For some reason when I'm running the website and trying to store value from session to database an error is being displayed with the following message "Procedure or function OrderFromCart has too many arguments specified". OrderFromCart is the name of the stored procedure. Any Ideas??ThanksInter FC
View 11 Replies
View Related
Apr 6, 2006
My stored procedure: ALTER PROCEDURE [dbo].[ShortUpdateSurvey]
@s_survey_id int,
@s_survey_num varchar(10),
@s_job_address varchar(30),
@s_job_city varchar(20),
@s_client_name varchar(50),
@s_date_ordered datetime,
@s_date_required datetime,
@s_amount money
AS
SET NOCOUNT OFF;
UPDATE [survey_master]
SET
[survey_num] = @s_survey_num,
[job_address] = @s_job_address,
[job_city] = @s_job_city,
[client_name] = @s_client_name,
[date_ordered] = @s_date_ordered,
[date_required] = @s_date_required,
[amount] = @s_amount
WHERE [survey_id] = @s_survey_id My ASP code:
<asp:BoundField DataField="survey_id" HeaderText="Survey ID" SortExpression="survey_id" />
<asp:BoundField DataField="survey_num" HeaderText="Survey Num." SortExpression="survey_num" />
<asp:BoundField DataField="job_address" HeaderText="Address" SortExpression="job_address" />
<asp:BoundField DataField="job_city" HeaderText="City" SortExpression="job_city" />
<asp:BoundField DataField="client_name" HeaderText="Client" SortExpression="client_name" ReadOnly="True" />
<asp:BoundField DataField="date_ordered" HeaderText="Ordered" SortExpression="date_ordered" DataFormatString="{0:d}" HtmlEncode="False" />
<asp:BoundField DataField="date_required" HeaderText="Needed" SortExpression="date_required" DataFormatString="{0:d}" HtmlEncode="False" />
<asp:BoundField DataField="amount" HeaderText="Amount" SortExpression="amount" />
...
SelectCommand="ShortAddressSearch"
SelectCommandType="StoredProcedure"
UpdateCommand="ShortUpdateSurvey"
UpdateCommandType="StoredProcedure">
...
<UpdateParameters>
<asp:Parameter Name="s_survey_id" Type="Int32" />
<asp:Parameter Name="s_survey_num" Type="String" />
<asp:Parameter Name="s_job_address" Type="String" />
<asp:Parameter Name="s_job_city" Type="String" />
<asp:Parameter Name="s_client_name" Type="String" />
<asp:Parameter Name="s_date_ordered" Type="DateTime" />
<asp:Parameter Name="s_date_required" Type="DateTime" />
<asp:Parameter Name="s_amount" Type="Decimal" />
...
and once again, the error message:
"Procedure or function ShortUpdateSurvey has too many arguments specified."
TIA
View 3 Replies
View Related
Jun 28, 2007
Hello.
Newbie here. I've only been using SQL for about a year now and have some minor questions about sql objects that reference other objects.
We have some views which reference other views in the joins. I will call one the primary view and the one being referenced in the joins as the secondary view.
Recently we made changes to the secondary view.
After which the primary views which referenced it would not work because of this change and had to be 'refreshed' by using drop/create scripts which essentially just dropped it and recreated the exact same view. I do not recall the exact error message that was returned other than it seemed to suggest that it could no longer see the secondary view since it had been changed. Nothing in the primary view was changed in any way, just the secondary.
Some here where I work have suggested off hand that this was a recompile of the primary view because the contents of the secondary changed.
My questions are:
1. Exactly why did this happen and is there a proper name for it when it does?
2. The same problem does not seem to occur when we have stored procedures referencing views in the joins which had just been changed. Why is that?
Thanks for any help on the matter. I greatly appreciate it.
View 3 Replies
View Related
Feb 22, 2007
Hello,
to make a report easier I'm developing it using a view of joined views of joined views.
Is there any significant performance penalty as opposed to just having one big select?
Cheers.
View 1 Replies
View Related
Sep 13, 2006
Can someone help me with this? For the life of me, I cannot figure out why I recieve this error: Procedure or function usp_ContactInfo_Update has too many arguments specified.Here is my code: <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"SelectCommand="usp_ContactInfo_Select" SelectCommandType="StoredProcedure" UpdateCommand="usp_ContactInfo_Update"UpdateCommandType="StoredProcedure"><UpdateParameters><asp:Parameter Name="Division" Type="String" /><asp:Parameter Name="Address" Type="String" /><asp:Parameter Name="City" Type="String" /><asp:Parameter Name="State" Type="String" /><asp:Parameter Name="Zip" Type="String" /><asp:Parameter Name="Phone" Type="String" /><asp:Parameter Name="TollFree" Type="String" /><asp:Parameter Name="Fax" Type="String" /><asp:Parameter Name="Email" Type="String" /><asp:Parameter Name="Res" Type="Boolean" /><asp:Parameter Name="Res_Rec" Type="Boolean" /><asp:Parameter Name="Com" Type="Boolean" /><asp:Parameter Name="Com_Rec" Type="Boolean" /><asp:Parameter Name="Temp" Type="Boolean" /><asp:Parameter Name="Temp_Rec" Type="Boolean" /><asp:Parameter Name="Port" Type="Boolean" /><asp:Parameter Name="Land" Type="Boolean" /><asp:Parameter Name="Drop" Type="Boolean" /></UpdateParameters><SelectParameters><asp:ProfileParameter Name="DivID" PropertyName="Division" Type="String" /></SelectParameters></asp:SqlDataSource>Here is my Stored Proc:ALTER PROCEDURE dbo.usp_ContactInfo_Update @Division varchar(1),@Address varchar(50),@City varchar(50),@State varchar(2),@Zip varchar(10),@Phone varchar(20),@TollFree varchar(20),@Fax varchar(20),@Email varchar(50),@Res bit,@Res_Rec bit,@Com bit,@Com_Rec bit,@Temp bit,@Temp_Rec bit,@Port bit,@Land bit,@Drop bit/*(@parameter1 int = 5,@parameter2 datatype OUTPUT)*/AS/* SET NOCOUNT ON */ UPDATE tblDivisionSET Division = @Division, Address = @Address, City = @City, State = @State, Zip = @Zip, Phone = @Phone, TollFree = @TollFree, Fax = @Fax, Email = @Email,Residential = @Res, Residential_Recycling = @Res_Rec, Commercial = @Com, Commercial_Recycling = @Com_Rec, Temp = @Temp, Temp_Recycling = @Temp_Rec, Portable_Restrooms = @Port, Landscaping = @Land, Drop_Off_Center = @DropWHERE (Division = @Division) RETURNAny Help is greatly appreciated!
View 2 Replies
View Related
May 26, 2008
i have written procedure like belowALTER PROCEDURE GetDetails
(@vpid int,
@vpname varchar(30) OUTPUT,
@vprice int OUTPUT
)
ASselect @vpname=productname,@vprice=price from fastfood where prod_id=@vpid
RETURN
and codeSqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["con"].ConnectionString;SqlCommand cmd = new SqlCommand("GetDetails",con);cmd.CommandType = CommandType.StoredProcedure;
con.Open();
Hashtable items=new Hashtable();items = (Hashtable)Session["basketdata"];string name,price;
foreach(int s in items.Keys)
{
SqlParameter p1 = new SqlParameter("@vpid", SqlDbType.Int, 10);p1.Direction = ParameterDirection.Input;
p1.Value = s;
cmd.Parameters.Add(p1);
//cmd.Parameters.Add("@vpid", SqlDbType.Int, 10).Value=s;cmd.Parameters.Add("@vpname", SqlDbType.Char, 30).Direction=ParameterDirection.Output; cmd.Parameters.Add("@vprice", SqlDbType.Int, 10).Direction=ParameterDirection.Output;
cmd.ExecuteNonQuery();
name = cmd.Parameters["@vpname"].Value.ToString();price = cmd.Parameters["@vprice"].Value.ToString();
%>
}
showing too many arguments to procedure
View 2 Replies
View Related
Jun 15, 2000
Hi,
In Oracle we can use the arguments for the Cursor, it's very useful. Not sure how to do it in MS SQL Server 7.0.
For example, in SQL server we use the following cursor in a stored procedure,
select @intID =10
DECLARE cur_test CURSOR FOR
select object_id, object_name from objects
where object_id = @intID
OPEN ....
FETCH ....
....
How about I need to change the @intID for the cursor based on logical condition in the code after a while??
Am I supposed to close the cursor cur_test and re-declare it?? Is there any way to make the code neat and short?
Any idea/help would be greatly appreciated!
Dana Jian
View 1 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
Nov 7, 2007
I am trying to delete from a SQL table using two arguments, I currently use the following on the aspx page: <ItemTemplate><asp:LinkButton ID="cmdDeleteJob" runat="server" CommandName="CancelJob" Text="Delete" CssClass="CommandButton" CommandArgument='<%# Bind("Type_of_service") %>' OnClientClick="return confirm('Are you sure you want to delete this item?');"></asp:LinkButton></ItemTemplate> and then I use the following on the aspx.vb page: If e.CommandName = "CancelJob" Then Dim typeService As Integer = CType(e.CommandArgument, Integer) Dim typeDesc As String = "" Dim wsDelete As New page1 wsDelete.deleteAgencySvcs(typeService) gvTech.DataBind() I need to be able to pick up two CommandArguments.
View 4 Replies
View Related
Dec 11, 2007
Hi, I'm a bit stumped as to how to do this.I have a string[] with a list of users, and I want to query my database to select only the users in this array and bind the datasource to a GridView, but I don't know how to write an SQL query to search for multiple results from the same field.
E.g. Say I have two results in my string[], fred and bob.How can I select data from the database for just those two users - "SELECT * FROM tblUsers WHERE UserName='bob' AND ??";
IF this is possible, I also need to bind it to a gridview. I tried the following, but it didn't work as I needed it to:
for(int a = 0; a < userArray.Length; a++){ conn.Open(); SqlCommand command = new SqlCommand("SELECT * FROM tblUsers WHERE UserName='" + userArray[a] + "'", conn); SqlDataReader reader = command.ExecuteReader(); grid.DataSource = reader; grid.DataBind(); conn.Close()}
That 'worked', but as I'm sure you can see, the data that was bound to the gridview was only the last result found, not the whole result set.
Any help is greatly appreciated.
View 4 Replies
View Related
Jul 20, 2004
"Procedure or function sptblTrgFACalculator_Insert_v2 has too many arguments specified"
This error was produced when i tried to insert 12 arguments into my table.Is there a limit to the number of arguments you can pass into your stored procedure?
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
Feb 18, 2006
Hello All,
I am having a very strange problem which I cannot figure out. I am using the ASP.NET 2.0 SqlDataSource control to insert a news item into a SQL Express database. When inserting the a message I receive the following error: Procedure or function has too many arguments specified
However according to me every thing adds up. Can anyone please help me figure out what is wrong? Here is the code:
SqlDataSource: <asp:SqlDataSource ID="sqlNews" runat="server" ConnectionString="<%$ ConnectionStrings:FlevoOptiekDB %>" SelectCommandType="StoredProcedure" SelectCommand="dbo.usp_News_ByID" InsertCommandType="StoredProcedure" InsertCommand="dbo.usp_News_Insert" UpdateCommandType="StoredProcedure" UpdateCommand="dbo.usp_News_Update" DeleteCommandType="StoredProcedure" DeleteCommand="dbo.usp_News_Delete" OldValuesParameterFormatString="{0}"> <SelectParameters> <asp:QueryStringParameter Name="p_iNewsID" QueryStringField="news_ID" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="p_dtmPublished" Type="DateTime" /> <asp:Parameter Name="p_sTitle" /> <asp:Parameter Name="p_sDescription" /> <asp:Parameter Name="p_sStaticUrl" /> <asp:Parameter Name="p_iPhotoID" /> <asp:Parameter Name="p_iNewsID" /> <asp:Parameter Name="p_iAlbumID" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="p_dtmPublished" Type="DateTime" /> <asp:Parameter Name="p_sTitle" /> <asp:Parameter Name="p_sDescription" /> <asp:Parameter Name="p_sStaticUrl" /> <asp:Parameter Name="p_iPhotoID" /> <asp:Parameter Name="p_iAlbumID" /> </InsertParameters> <DeleteParameters> <asp:QueryStringParameter Name="p_iNewsID" QueryStringField="news_ID" /> </DeleteParameters> </asp:SqlDataSource>Stored procedure:ALTER PROCEDURE dbo.usp_News_Insert( @p_sTitle VARCHAR(256), @p_sDescription TEXT, @p_sStaticUrl VARCHAR(256), @p_dtmPublished DATETIME, @p_iPhotoID INT, @p_iAlbumID INT)AS /* SET NOCOUNT ON */ INSERT INTO dbo.tbNews(news_Title, news_Description, news_StaticUrl, news_Published, photo_ID, album_ID) VALUES(@p_sTitle, @p_sDescription, @p_sStaticUrl, @p_dtmPublished, @p_iPhotoID, @p_iAlbumID) RETURN
Thanks, Maurits
View 3 Replies
View Related
Mar 7, 2006
I have tried to introduce information in webform with sp and she leaves the following error
View 1 Replies
View Related
Dec 31, 2005
Hello. I am pretty new to SQL Stored Procedure, and ran into a problem. I am guessing there is a simple solution to this, as I am self-teaching myself this stuff.
I currently have a procedure that creates a new table, by reading in columns from a variety of Linked Servers (ODBC connection to to Sybase databases)
I will want to generalize a procedure by setting as arguments the ODBC connection name and the name of the new table that will be created ("CREATE TABLE") so I can pass these in.
As a test of this idea, I created this as a simple procedure, but I get a syntax error when I try to Check Syntax this. Do I have to do something else when I reference the string "argu1" to specify a new table name, or an OPEN QUERY Linked table name? Thanks and Happy New Year!
CREATE PROCEDURE gis.pr_PARCEL_TEST( @argu1 char(25)) AS
CREATE TABLE @argu1
GO
View 2 Replies
View Related
Aug 31, 2007
I'm kind of new at doing something like this. I'm trying to pull data into a results that exists in one of two databases. It works fine with query analyzer
but gives me the error "has no parameters and arguments were supplied" when I try to convert it to a stored procedure.
The procedure is as follows, any help would be appreciated.
CREATE PROCEDURE sp_getInvoiceNoTest AS
declare @InVoiceNo as VarChar(30)
delete From Invoice_NBR
Insert into Invoice_NBR (Tran_NBr,ADDR_Name,ADDR_Line2,ADDR_Line3,CITY_NAM E,State_Name,ADDR_NAME2,ADDR_LINE4,ADDR_LINE5,CITY _NAME2,State_Name2)
select a.TranNo,b.AddrLine1,b.AddrLine2,b.AddrLine3,b.cit y,b.StateID,c.AddrName,c.AddrLine2,c.AddrLine3,c.C ity,c.StateID
from Colucw17.Acuity_App.dbo.tarInvoice as a
inner join
Colucw17.Acuity_App.dbo.tciAddress as b
on a.BilltoAddrKey=b.AddrKey
inner join
Colucw17.Acuity_App.dbo.tciAddress as c
on a.BilltoAddrKey=c.AddrKey and a.BilltoAddrKey=a.BilltoCustAddrKey
inner join
Colucw17.Acuity_App.dbo.tarCustomer as d
on a.CustKey=d.CustKey
inner join
Colucw17.Acuity_App.dbo.tciContact as f
on a.confirmtoCntctKey=f.CntctKey
where a.CreateuserID<>'admin' and a.TranNo='@InvoiceNo'
--Insert into Invoice_NBr (Tran_NBr,ADDR_Name,ADDR_Line2,ADDR_Line3,CITY_NAM E,State_Name,ADDR_NAME2,ADDR_LINE4,ADDR_LINE5,CITY _NAME2,State_Name2)
select a.TranNo,b.AddrLine1,b.AddrLine2,b.AddrLine3,b.cit y,b.StateID,c.AddrName,c.AddrLine2,c.AddrLine3,c.C ity,c.StateID
from Colucw17.CSM_App.dbo.tarInvoice as a
inner join
Colucw17.CSM_App.dbo.tciAddress as b
on a.BilltoAddrKey=b.AddrKey
inner join
Colucw17.CSM_App.dbo.tciAddress as c
on a.BilltoAddrKey=c.AddrKey and a.BilltoAddrKey=a.BilltoCustAddrKey
inner join
Colucw17.CSM_App.dbo.tarCustomer as d
on a.CustKey=d.CustKey
inner join
Colucw17.CSM_App.dbo.tciContact as f
on a.confirmtoCntctKey=f.CntctKey
where a.CreateuserID<>'admin' and a.TranNo='@InvoiceNo'
GO
View 4 Replies
View Related
Oct 13, 2007
Hi,
we can use 'sp_executesql' to execute any statemens. I have made a search and people, seems, need the dynamic sql only to process some table/cloumn unknown in advance. My idea is that the dynamic SQL feature is ideal for passing blocks of code (aka delegates). Particularily, you may require to execute different procedures under some acquired locks. A procedure would acquire the locks, execute the code and release the locks. The problem is, however, that I cannot find the specification for the variable length parameters. It seems not feasible for SPs. Nevertheless, the 'sp_executesql itself does accept the variable number of parameters. How? Can we look at the defenition?
View 2 Replies
View Related
May 25, 2008
Hi all,
I have got this issue when I am trying to store an Image on a database through a stored procedure. I give you the code in C# and the stored procedure
Code Snippet
//I have got these two variables with the ID(foreign key) and the array of bytes of the Image (the values are OK)
int ID_Inmueble
byte[] imagen -- dimension 26246
SqlConnection conn = new SqlConnection(...) //The conexion works fine (I tested it).
SqlCommand cmd = new SqlCommand();
SqlParameter[] param = new SqlParameter[2];
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "InsertaUnaFoto";
cmd.Connection = conn;
param[0] = new SqlParameter("@ID_Inmueble", SqlDbType.BigInt);
param[0].Value = ID_Inmueble;
param[1] = new SqlParameter("@Foto", SqlDbType.Image);
param[1].Value = imagen;
cmd.Parameters.AddRange(param);
SqlDataAdapter da = new SqlDataAdapter(conexion.GetSqlCommand());
da.Fill(ds); //here I got the error
The stored Procedure
T
Code Snippet
ALTER PROCEDURE dbo.InsertaUnaFoto
(@ID_Inmueble bigint,
@Foto Image)
AS
INSERT into Fotos (ID_Inmueble, Foto) values (@ID_Inmueble, @Foto)
Many Thanks,
View 3 Replies
View Related
Mar 3, 2008
Hello,
When I try to call a stored procedure I get an SQL-exception reading "Procedure or function insert_member has too many arguments specified."
As far as I can see the number of parameters in the application match the number of arguments in the stored procedure. I supply 10 parameters in the application and 10 in the procedure. Is the location of the declaration of the argument cgpID a problem?
ALTER PROCEDURE [dbo].[insert_member]
(
@mbrFirstName nvarchar(15),
@mbrLastName nvarchar(15),
@mbrStreetAddress nvarchar(15),
@mbrPostalAddress nvarchar(15),
@mbrTelephoneHome nvarchar(15),
@mbrTelephoneJob nvarchar(15),
@mbrEmail nvarchar(15),
@mbrActivityGroupID int,
@mbrPaymentMethod int
)
AS
INSERT INTO dbo.member(mbrFirstName, mbrLastName, mbrStreetAddress, mbrPostalAddress, mbrTelephoneHome, mbrTelephoneJob, mbrEmail)
VALUES (@mbrFirstName, @mbrLastName, @mbrStreetAddress, @mbrPostalAddress, @mbrTelephoneHome, @mbrTelephoneJob, @mbrEmail)
declare @cgpID int
set @cgpID = (select cgpID from currentgroup where cgpActivityGroupID = @cgpActivityGroupID)
INSERT INTO member_currentgroup
(mbrID, cgpID, mcgPaymentMethod)
values
(@@identity, @cgpID, @mcgPaymentMethod)
View 8 Replies
View Related
Mar 22, 2007
Hi
While coding with ASP.NET 2.0 I came across this error "Procedure or function InsertUpdateArtist_Tracks has too many arguments specified."
Its quite frustrating because I dont know what arguments are being referred to because I've clearly assigned the correct parameters with their correct values to this Stored procedure :InsertUpdateArtist_Tracks
Please can some help me with this? is there something fundamentality wrong with my code (Below) or is this a know Microsoft stuff up?
or by the way I'm using SQL Server 2005 and ASP.NET 2.0
Below is my sample code:
..............
'Insert or Update Artist_tracks table
Response.Write("<br><b>Inserting or Updating Artist_tracks table</b>")
AT_Title = SearchArtistsResults(i).title
AT_Meta_ID = SearchArtistsResults(i).meta_id
AT_AA_ID = AA_ID
Dim ParamTitle As SqlParameter
Dim ParamMeta As SqlParameter
Dim ParamAA_ID As SqlParameter
dbCommand.CommandText = "InsertUpdateArtist_Tracks"
dbCommand.CommandType = Data.CommandType.StoredProcedure
dbCommand.Connection = conn
ParamTitle = dbCommand.Parameters.Add(New SqlParameter("@AT_Title", Data.SqlDbType.VarChar, 50))
ParamTitle.Value = AT_Title
ParamTitle.Direction = Data.ParameterDirection.Input
Response.Write("<br>Sent through this Title =" & AT_Title)
ParamMeta = dbCommand.Parameters.Add(New SqlParameter("@AT_Meta_ID", Data.SqlDbType.Int))
ParamMeta.Value = AT_Meta_ID
ParamMeta.Direction = Data.ParameterDirection.Input
Response.Write("<br>Sent through this Meta_id =" & AT_Meta_ID)
ParamAA_ID = dbCommand.Parameters.Add(New SqlParameter("@AT_AA_ID", Data.SqlDbType.Int))
ParamAA_ID.Value = AT_AA_ID
ParamAA_ID.Direction = Data.ParameterDirection.Input
Response.Write("<br>Sent through this AT_AA_ID =" & AT_AA_ID)
conn.Open()
dbCommand.ExecuteNonQuery()
conn.Close()
..................
Thanks in Advance
View 2 Replies
View Related
Sep 19, 2007
I'm Deleting my record in the database using stored procedure and I'm always getting this error :Procedure or function DeleteSender has too many arguments specified. same as I insert record... here's my stored proc for delete:set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[DeleteSender]@RecNo int ASDELETE FROM [Sender] WHERE [RecNo] = @RecNo for insert:set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[InsertSender](@SenderID nvarchar(50), @SenderLastName nvarchar(50), @SenderFirstName nvarchar(50), @SenderAddress nvarchar(50), @SenderCity nvarchar(50), @SenderState nvarchar(25), @SenderZip nvarchar(10), @SenderTel nvarchar(25), @FS int, @TB int, @Status nvarchar(10), @EndBalance money)ASINSERT INTO [Sender] ([SenderID], [SenderLastName], [SenderFirstName], [SenderAddress], [SenderCity], [SenderState], [SenderZip], [SenderTel], [FS], [TB], [Status], [EndBalance]) VALUES (@SenderID, @SenderLastName, @SenderFirstName, @SenderAddress, @SenderCity, @SenderState, @SenderZip, @SenderTel, @FS, @TB, @Status, @EndBalance) aspx:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><%@ Register src="FormControl.ascx" TagName="FormControl" TagPrefix="uc1" %><%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %><%@ Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="radC" %><%@ Register Assembly="RadInput.Net2" Namespace="Telerik.WebControls" TagPrefix="radI" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Sender</title> <link href="sender.css" rel="stylesheet" type="text/css" /></head><body> <form id="form1" runat="server"> <div class="wrapper"> <div class="banner"> <radG:RadGrid ID="rgSender" runat="server" GridLines="None" DataSourceID="sqlDataSource1" EnableAJAX="True" ShowStatusBar="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowAutomaticDeletes="True" Skin="3D" AutoGenerateColumns="False"> <MasterTableView CommandItemDisplay="Top" DataKeyNames="RecNo" DataSourceID="sqlDataSource1"> <ExpandCollapseColumn Visible="False"> <HeaderStyle Width="19px" /> </ExpandCollapseColumn> <RowIndicatorColumn Visible="False"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> <EditFormSettings EditFormType="Template"> <FormTemplate> <table border="0"> <tr> <td> <asp:Label ID="Label1" runat="server" Text="Record No.:" Visible='<%# rgSender.EditIndexes.Count > 0 %>'></asp:Label></td> <td> <radI:RadTextBox ID="rtbRecNo" runat="server" Text='<%# Bind("RecNo") %>' Visible='<%# rgSender.EditIndexes.Count > 0 %>'> </radI:RadTextBox></td> <td> <asp:Label ID="Label8" runat="server" Text="Zip Code:"></asp:Label></td> <td> <radI:RadTextBox ID="rtbZip" runat="server" Text='<%# Bind("SenderZip") %>'> </radI:RadTextBox></td> </tr> <tr> <td> <asp:Label ID="Label2" runat="server" Text="Sender ID:"></asp:Label></td> <td><radI:RadTextBox ID="rtbSenderID" runat="server" Text='<%# Bind("SenderID") %>'> </radI:RadTextBox></td> <td> <asp:Label ID="Label9" runat="server" Text="Telephone #:"></asp:Label></td> <td><radI:RadTextBox ID="rtbTel" runat="server" Text='<%# Bind("SenderTel") %>'> </radI:RadTextBox></td> </tr> <tr> <td><asp:Label ID="Label3" runat="server" Text="First Name:"></asp:Label></td> <td><radI:RadTextBox ID="rtbFName" runat="server" Text='<%# Bind("SenderFirstName") %>'> </radI:RadTextBox></td> <td> <asp:Label ID="Label10" runat="server" Text="Total Free Sent:"></asp:Label></td> <td><radI:RadTextBox ID="rtbFS" runat="server" Text='<%# Bind("FS") %>'> </radI:RadTextBox></td> </tr> <tr> <td><asp:Label ID="Label4" runat="server" Text="Last Name:"></asp:Label></td> <td><radI:RadTextBox ID="rtbLName" runat="server" Text='<%# Bind("SenderLastName") %>'> </radI:RadTextBox></td> <td><asp:Label ID="Label11" runat="server" Text="Total Box Sent:"></asp:Label></td> <td> <radI:RadTextBox ID="rtbBS" runat="server" Text='<%# Bind("TB") %>'> </radI:RadTextBox></td> </tr> <tr> <td> <asp:Label ID="Label5" runat="server" Text="Address:"></asp:Label></td> <td><radI:RadTextBox ID="rtbAddress" runat="server" Text='<%# Bind("SenderAddress") %>'> </radI:RadTextBox></td> <td><asp:Label ID="Label12" runat="server" Text="Status:"></asp:Label></td> <td><radI:RadTextBox ID="rtbStatus" runat="server" Text='<%# Bind("Status") %>'> </radI:RadTextBox></td> </tr> <tr> <td><asp:Label ID="Label6" runat="server" Text="City:"> </asp:Label></td> <td> <radI:RadTextBox ID="rtbCity" runat="server" Text='<%# Bind("SenderCity") %>'> </radI:RadTextBox></td> <td><asp:Label ID="Label13" runat="server" Text="End Balance:"></asp:Label></td> <td><radI:RadTextBox ID="rtbEndBalance" runat="server" Text='<%# Bind("EndBalance") %>'> </radI:RadTextBox></td> </tr> <tr> <td> <asp:Label ID="Label7" runat="server" Text="State:"></asp:Label></td> <td><radI:RadTextBox ID="rtbState" runat="server" Text='<%# Bind("SenderState") %>'> </radI:RadTextBox> </td> <td> <asp:Button ID="btnUpdate" Text='<%# IIf(CType(Container,GridItem).OwnerTableView.IsItemInserted,"Insert","Update") %>' runat="server" CommandName='<%# IIf(CType(Container,GridItem).OwnerTableView.IsItemInserted,"PerformInsert","Update") %>'></asp:Button> <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button></td> </tr> </table> </FormTemplate> </EditFormSettings> <Columns> <radG:GridEditCommandColumn ButtonType="ImageButton"/> <radG:GridTemplateColumn HeaderText="Sender ID" UniqueName="TCSenderID"> <ItemTemplate> <asp:Label ID="lblSenderID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "SenderID") %>'></asp:Label> </ItemTemplate> </radG:GridTemplateColumn> <radG:GridTemplateColumn HeaderText="First Name" UniqueName="TCSenderFName"> <ItemTemplate> <asp:Label ID="lblSenderFName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "SenderFirstName") %>'></asp:Label> </ItemTemplate> </radG:GridTemplateColumn> <radG:GridTemplateColumn HeaderText="Last Name" UniqueName="TCSenderLName"> <ItemTemplate> <asp:Label ID="lblSenderLName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "SenderLastName") %>'></asp:Label> </ItemTemplate> </radG:GridTemplateColumn> <radG:GridButtonColumn UniqueName="ButtonColumn" ConfirmText="Are you sure?" Text="Delete" CommandName="Delete" ButtonType="ImageButton" ImageUrl="RadControls/Grid/Skins/Default/Delete.gif" /> </Columns> </MasterTableView> </radG:RadGrid></div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConString_TO_Cargo %>" SelectCommandType="StoredProcedure" SelectCommand="sp_SelectSender" DeleteCommandType="StoredProcedure" DeleteCommand="DeleteSender" InserCommandType="StoredProcedure" InsertCommand="InsertSender" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [Sender] SET [SenderID] = @SenderID, [SenderLastName] = @SenderLastName, [SenderFirstName] = @SenderFirstName, [SenderAddress] = @SenderAddress, [SenderCity] = @SenderCity, [SenderState] = @SenderState, [SenderZip] = @SenderZip, [SenderTel] = @SenderTel, [FS] = @FS, [TB] = @TB, [Status] = @Status, [EndBalance] = @EndBalance WHERE [RecNo] = @original_RecNo AND [SenderID] = @original_SenderID AND [SenderLastName] = @original_SenderLastName AND [SenderFirstName] = @original_SenderFirstName AND [SenderAddress] = @original_SenderAddress AND [SenderCity] = @original_SenderCity AND [SenderState] = @original_SenderState AND [SenderZip] = @original_SenderZip AND [SenderTel] = @original_SenderTel AND [FS] = @original_FS AND [TB] = @original_TB AND [Status] = @original_Status AND [EndBalance] = @original_EndBalance"> <DeleteParameters> <asp:Parameter Name="RecNo" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="SenderID" Type="String" /> <asp:Parameter Name="SenderLastName" Type="String" /> <asp:Parameter Name="SenderFirstName" Type="String" /> <asp:Parameter Name="SenderAddress" Type="String" /> <asp:Parameter Name="SenderCity" Type="String" /> <asp:Parameter Name="SenderState" Type="String" /> <asp:Parameter Name="SenderZip" Type="String" /> <asp:Parameter Name="SenderTel" Type="String" /> <asp:Parameter Name="FS" Type="Int32" /> <asp:Parameter Name="TB" Type="Int32" /> <asp:Parameter Name="Status" Type="String" /> <asp:Parameter Name="EndBalance" Type="Decimal" /> <asp:Parameter Name="original_RecNo" Type="Int32" /> <asp:Parameter Name="original_SenderID" Type="String" /> <asp:Parameter Name="original_SenderLastName" Type="String" /> <asp:Parameter Name="original_SenderFirstName" Type="String" /> <asp:Parameter Name="original_SenderAddress" Type="String" /> <asp:Parameter Name="original_SenderCity" Type="String" /> <asp:Parameter Name="original_SenderState" Type="String" /> <asp:Parameter Name="original_SenderZip" Type="String" /> <asp:Parameter Name="original_SenderTel" Type="String" /> <asp:Parameter Name="original_FS" Type="Int32" /> <asp:Parameter Name="original_TB" Type="Int32" /> <asp:Parameter Name="original_Status" Type="String" /> <asp:Parameter Name="original_EndBalance" Type="Decimal" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="SenderID" Type="String" /> <asp:Parameter Name="SenderLastName" Type="String" /> <asp:Parameter Name="SenderFirstName" Type="String" /> <asp:Parameter Name="SenderAddress" Type="String" /> <asp:Parameter Name="SenderCity" Type="String" /> <asp:Parameter Name="SenderState" Type="String" /> <asp:Parameter Name="SenderZip" Type="String" /> <asp:Parameter Name="SenderTel" Type="String" /> <asp:Parameter Name="FS" Type="Int32" /> <asp:Parameter Name="TB" Type="Int32" /> <asp:Parameter Name="Status" Type="String" /> <asp:Parameter Name="EndBalance" Type="Decimal" /> </InsertParameters> </asp:SqlDataSource> <br /> <radG:RadGrid ID="rgSenderDetails" runat="server" AutoGenerateColumns="False" GridLines="None"> <MasterTableView> <ExpandCollapseColumn Visible="False"> <HeaderStyle Width="19px" /> </ExpandCollapseColumn> <RowIndicatorColumn Visible="False"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> </MasterTableView> </radG:RadGrid><br /> </div> </form></body></html> hope you can help me guys/// stings...
View 1 Replies
View Related
Sep 26, 2007
Hi all I having suffering from a strange behavior when trying to update. I receive the following error :
Here is my code: Procedure or function SavePhotoHotelLang has too many arguments specified.
<asp:SqlDataSource ID="SqlDataSourceHotelPhotoList" runat="server" ConnectionString="<%$ ConnectionStrings:smileDBConnectionString %>"SelectCommand="SELECT phl.PhotoHotelLangId, ph.smallfilepath, ph.photorank, pht.Type, phl.name, phl.description, ph.PhotoHotelId FROM datPhotoHotel ph
INNER JOIN datPhotoHotelType pht ON ph.PhotoHotelTypeId = pht.PhotoHotelTypeId
LEFT OUTER JOIN datPhotoHotelLang phl on ph.PhotoHotelId = phl.PhotoHotelId WHERE HotelId = @HotelId and ( LanguageId = @languageId or LanguageId is null)"
UpdateCommand="SavePhotoHotelLang" UpdateCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter Name="HotelId" QueryStringField="HotelId" Type="int32" />
<asp:ControlParameter Name="languageId" ControlID="ddlLanguageForGV" PropertyName="SelectedValue" Type="int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="name"/>
<asp:Parameter Name="Description" />
<asp:ControlParameter Name="languageId" ControlID="ddlLanguageForGV" PropertyName="SelectedValue"/>
<asp:Parameter Name="PhotoHotelLangId" />
<asp:Parameter Name="PhotoHotelId" />
</UpdateParameters>
</asp:SqlDataSource>
<Grids:BulkEditGridView
ID="GvHotelPhotoList" runat="server"
DataSourceID="SqlDataSourceHotelPhotoList" AutoGenerateColumns="false" SaveButtonID="saveBtn"
DataKeyNames="PhotoHotelLangId, PhotoHotelId">
<Columns>
<asp:TemplateField>
<itemtemplate>
<asp:Image id="smallimage" runat="server" ImageUrl='<%# Eval("smallFilePath") %>'></asp:Image>
</itemtemplate>
<Edititemtemplate>
<asp:Image id="smallimageedit" runat="server" ImageUrl='<%# Eval("smallFilePath") %>'></asp:Image>
</Edititemtemplate>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Name"/>
<asp:BoundField DataField="Description" FooterText="Description"/>
<asp:BoundField DataField="photorank" HeaderText="Rank" ReadOnly="true"/>
<asp:BoundField DataField="Type" FooterText="Type" ReadOnly="true"/>
</Columns></Grids:BulkEditGridView>
">'>'>
alter procedure SavePhotoHotelLang @name varchar(100), @Description varchar(500), @languageId int, @PhotoHotelLangId int, @PhotoHotelId intasbegin
if ( @PhotoHotelLangId is null ) begin
insert into dbo.datPhotoHotelLang ( name, Description, languageId ) values (@name, @Description, @languageId, @PhotoHotelId) end else begin
update dbo.datPhotoHotelLang set name = @name, Description = @Description where PhotoHotelLangId = @PhotoHotelLangId
endend
View 1 Replies
View Related