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.
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
I get an error like 'Query failed for the datatset Reportsource.Procedure of function has too many arguments specified.' What could be the reason for this error?? please help me
I have just taken over the job of sorting out a rather poorly designed database. It looks like it was 'upsized' from an access database to the SQL server. The SQL server is the 2000 version.
Now I am trying to generate a report of what the students in the database are owing by referencing the Receipt table and then all the available payment methods and allocations. I was wondering if there was anyway to work out data being displayed twice (Let me demonstrate)
Note1: All the tables are linked by a key of ReceiptNo. From what I can see there is a table for every payment type and allocation but no link between the two other then the receipt number.
Using the query: SELECT T_Receipt.ReceiptNo, T_cheque.Amount AS Chq_Amount, T_credit.Amount AS Cre_Amount, StandingOrder.Amount AS Stn_Amount, T_BankTransfer.amount AS Bnk_Amount, T_cash.TotalAmount AS Cas_Amount, T_RentPayment.AmountPayed AS Ren_Paid, T_AdminPayment.AmountPaid AS Adm_Paid, T_InternetBilling.Total AS Int_Paid, T_Utilities.AmountPaid AS Util_Amount, T_InvoicePayment.amountPaid AS Inv_Paid, T_OtherPayments.paymentAmount AS Oth_Paid, T_parkingBill.paymentAmount AS Prk_Paid, T_TelephoneBills.TelephoneCredit AS Tel_Paid, T_DepositPayment.[Deposit payment] AS Dep_Amount, T_Receipt.cancelled AS Canceled, T_Receipt.RemittanceReceiptNo AS Rec_Ref, T_Receipt.Student FROM T_Receipt INNER JOIN T_DepositPayment ON T_Receipt.ReceiptNo = T_DepositPayment.receiptNo LEFT OUTER JOIN T_RentPayment ON T_Receipt.ReceiptNo = T_RentPayment.RentPaymentNo LEFT OUTER JOIN StandingOrder ON T_Receipt.ReceiptNo = StandingOrder.ReceiptNo LEFT OUTER JOIN T_TelephoneBills ON T_Receipt.ReceiptNo = T_TelephoneBills.ReceiptNo LEFT OUTER JOIN T_parkingBill ON T_Receipt.ReceiptNo = T_parkingBill.ReceiptNo LEFT OUTER JOIN T_OtherPayments ON T_Receipt.ReceiptNo = T_OtherPayments.ReceiptNo LEFT OUTER JOIN T_InvoicePayment ON T_Receipt.ReceiptNo = T_InvoicePayment.receiptNo LEFT OUTER JOIN T_cash ON T_Receipt.ReceiptNo = T_cash.ReceiptNo LEFT OUTER JOIN T_AdminPayment ON T_Receipt.ReceiptNo = T_AdminPayment.ReceiptNo LEFT OUTER JOIN T_BankTransfer ON T_Receipt.ReceiptNo = T_BankTransfer.receiptNo LEFT OUTER JOIN T_Utilities ON T_Receipt.ReceiptNo = T_Utilities.receiptNo LEFT OUTER JOIN T_credit ON T_Receipt.ReceiptNo = T_credit.ReceiptNo LEFT OUTER JOIN T_cheque ON T_Receipt.ReceiptNo = T_cheque.ReceiptNo LEFT OUTER JOIN T_InternetBilling ON T_Receipt.ReceiptNo = T_InternetBilling.ReceiptNo GROUP BY T_Receipt.Student, T_Receipt.ReceiptNo, T_cheque.Amount, T_credit.Amount, StandingOrder.Amount, T_BankTransfer.amount, T_cash.TotalAmount, T_AdminPayment.AmountPaid, T_InternetBilling.Total, T_Utilities.AmountPaid, T_InvoicePayment.amountPaid, T_OtherPayments.paymentAmount, T_parkingBill.paymentAmount, T_TelephoneBills.TelephoneCredit, T_Receipt.cancelled, T_Receipt.RemittanceReceiptNo, T_DepositPayment.[Deposit payment], T_RentPayment.AmountPayed, T_Receipt.Student HAVING (T_Receipt.Student LIKE N'06%')
Which gives a result of:
RecNo. 30429 Cheque 250 Deposit 250
30429 679.98 250
This is fine but when I do analysis on this it appears as though the student has paid two deposit payments. I was wondering with out querying each table independently from an application if there was a criteria to specify that I only get one deposit result. So as such say, give me all the payments but I only want one result from the other tables. I though about discrete but that wouldn't work here.
Howdy folks. I have a SELECT question for you. Or maybe a WHERE question. That I am not sure is part of the problem. My application is ASP.NET 2.0, and I’d like to avoid getting into stored procedures right now, if I could.
I am trying to summarize the order status for each customer in the database (SQL Server 2005, by the way). I want to provide two counts: the number of open jobs per customer, and the number of rush jobs per customer. Something like this:
SELECT CustID, MAX(CustName) AS CustName, COUNT (*) AS JobOpen FROM Customers INNER JOIN Jobs ON JobCustID = CustID WHERE (JobDone = 0) GROUP BY CustID
As you can see, it finds from the Jobs table all jobs that are not done (JobDone is a T/F field), joins the Jobs and Customers tables, groups by CustID, and counts the totals in each CustID group. It works great in outputting the first three columns that I am looking for.
But I cannot come up with a simple way to add JobRush (also a T/F field), because it needs a different WHERE clause than the one JobOpen uses. It would need
WHERE (JobRush = 1)
So maybe my question should be: how do I use multiple WHERE clauses, each with its own COUNT?
I did mess around with Common Table Expressions, and managed to build two CTEs (one with JobOpen results and the other with JobRush results) that I joined together. It worked in Studio Manager, but my ASP.NET page didn’t like it. I guess that means I could learn stored procedures, but wow I’d love to just have a nice complete SELECT command for my page.
Thanks for reading all this. Any input is greatly appreciated. Matt
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
When viewing an estimated query plan for a stored procedure with multiple query statements, two things stand out to me and I wanted to get confirmation if I'm correct.
1. Under <ParameterList><ColumnReference... does the xml attribute "ParameterCompiledValue" represent the value used when the query plan was generated?
2. Does each query statement that makes up the execution plan for the stored procedure have it's own execution plan? And meaning the stored procedure is made up of multiple query plans that could have been generated at a different time to another part of that stored procedure?
I have two tables .. in one (containing user data, lets call it u).The important fields are:u.userName, u.userID (uniqueidentifier) and u.workgroupID (uniqueidentifier)The second table (w) has fieldsw.delegateID (uniqueidentifier), w.workgroupID (uniqueidentifier) The SP takes the delegateID and I want to gather all the people from table u where any of the workgroupID's for that delegate match in w. one delegateID may be tied to multiple workgroupID's. I know I can create a temporary table (@wgs) and do a: INSERT INTO @wgs SELECT workgroupID from w WHERE delegateID = @delegateIDthat creates a result set with all the workgroupID's .. this may be one, none or multipleI then want to get all u.userName, u.userID FROM u WHERE u.workgroupIDThis query works on an individual workgroupID (using another temp table, @users to aggregate the results was my thought, so that's included) INSERT INTO @users SELECT u.userName,u.userID FROM tableU u LEFT JOIN tableW w ON w.workgroupID = u.workgroupID WHERE u.workgroupID = @workGroupIDI'm trying to avoid looping or using a CURSOR for the performance hit (had to kick the development server after one of the cursor attempts yesterday)Essentially what I'm after is: SELECT u.userName,u.userID FROM tableU u LEFT JOIN tableW w ON w.workgroupID = u.workgroupID WHERE u.workgroupID = (SELECT workgroupID from w WHERE delegateID = @delegateID) ... but that syntax does not work and I haven't found another work around yet.TIA!
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
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;
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
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.
"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?
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?
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
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.
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
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
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?
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).
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)
Hi, I remember seeing a fancy query that checked for multiple fields in a table (I think using a select statement in the where clause but not sure), but can't remember how to do it... here is what I want to do (and maybe there is a much easier way). Thanks!
Table1 id item color 1 shoe red 2 shoe blue 3 coat green 4 coat black
Table2 item color shoe red coat green
I want everything in Table1 where item and color are not a match.
So my results should be: 2 shoe blue 4 coat black
I'm sorry if this is a dumb question... it's been that kind of a day!
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() ..................
Hi All, I'm getting this annoying message when I try to call my Sp on an insert. I've executed the SP straight from SQL Server 2005 Express and it works fine. but I think I have a problem how I'm calling it. The SP------------------------------------------------------------------------- ALTER PROCEDURE dbo.spInsertNewProduct( @productName nvarchar(50), @productSummary text, @productDesc text, @productPhoto int, @productFeaturelist text, @productTestimonials text, @productFile1 int, @productFile1_Title nvarchar(50), @productFile2 int, @productFile1_Title nvarchar(50), @NewProductID int OUTPUT)AS -- inserts new product INSERT INTO [tbl_products] ([productName], [productSummary], [productDesc], [productPhoto], [productFeaturelist], [productTestimonials], [productFile1], [productFile1_Title], [productFile2], [productFile2_Title]) VALUES (@productName, @productSummary, @productDesc, @productPhoto, @productFeaturelist, @productTestimonials, @productFile1, @productFile1_Title, @productFile2, @productFile2_Title); -- Read the just-inserted productID into @NewProductID SET @NewProductID = SCOPE_IDENTITY(); ------------------------------------------------------------------------- The DataSource------------------------------------------------------------------------- <asp:SqlDataSource ID="dsproduct" runat="server" ConnectionString="<%$ ConnectionStrings:myConn %>" InsertCommand="spInsertNewProduct" InsertCommandType="StoredProcedure"> <InsertParameters> <asp:Parameter Name="productName" Type="String" /> <asp:Parameter Name="productSummary" Type="String" /> <asp:Parameter Name="productDesc" Type="String" /> <asp:Parameter Name="productPhoto" Type="String" /> <asp:Parameter Name="productFeaturelist" Type="String" /> <asp:Parameter Name="productTestimonials" Type="String" /> <asp:Parameter Name="productFile1" Type="String" /> <asp:Parameter Name="productFile1_Title" Type="String" /> <asp:Parameter Name="productFile2" Type="String" /> <asp:Parameter Name="productFile2_Title" Type="String" /> <asp:Parameter Direction="Output" Name="NewProductID" Type="Int32" /> </InsertParameters> </asp:SqlDataSource>------------------------------------------------------------------------- In code behind I grab params from front end dropdowns:------------------------------------------------------------------------- Sub InsertProduct(ByVal Src As Object, ByVal Args As DetailsViewInsertEventArgs) dsProduct.InsertParameters("productPhoto").DefaultValue = CType(dvEditProduct.FindControl("ddlProdImage"), DropDownList).SelectedValue dsProduct.InsertParameters("productFile1").DefaultValue = CType(dvEditProduct.FindControl("ddlProdFile1"), DropDownList).SelectedValue dsProduct.InsertParameters("productFile2").DefaultValue = CType(dvEditProduct.FindControl("ddlProdFile2"), DropDownList).SelectedValue lblStatus.Text = "Product has been added to the database" End Sub------------------------------------------------------------------------- I can't see how in the VB front end file how there can be too many params? Any help is greatly appreciated!