| Author |
Topic |
|
Fearless_Shultz
Starting Member
6 Posts |
Posted - 2004-12-21 : 15:18:46
|
| I am quite new to using SQL Server having just moved over recently from access (shudders) so this is probably just a basic syntax issue... but I am trying to use @@identity, having inserted one set of values to insert another to a different table with the id value from the first.I am getting the errorProcedure or function sproc_NewUserHire has too many arguments specified. I have tried searching these forums to see if I can find an answer posted elsewhere but I keep getting error messages so I guess there are some issues going on server side.... anyways, my code is....CREATE PROCEDURE [dbo].[sproc_NewUserHire] (@FName varchar (50),@SName varchar (50),@Age int,@Occupation varchar (75),@Add1 varchar (100),@Add2 varchar (100),@Add3 varchar (100),@PostCode varchar (25),@City varchar (50),@Country varchar (50),@Nationality varchar (50),@TelNo varchar (50),@FaxNo varchar (50),@EmailAdd varchar (50),@Password varchar (50),@OnMailingList varchar(50),@CollectionDate datetime,@ReturnDate datetime,@CollectionLocationID int,@ReturnLocationID int,@VehicleID varchar (50),@DeliveryAddress varchar (500),@FlightNumber varchar (500),@AdditionalInfo varchar (500),@NumberOfDrivers int,@CSANumber int,@CSBNumber int,@CSCNumber int, @CSDNumber int,@VehicleDailyRate money,@VehicleTotalCost money,@TotalHireCost money)ASINSERT INTO tblUserDet (FName, SName, Age, Occupation, Add1, Add2, Add3, City, PostCode, City, Country, Nationality, TelNo, FaxNo, EmailAdd, Up, OnMailingList)VALUES(@FName, @SName, @Age, @Occupation, @Add1, @Add2, @Add3, @PostCode, @City, @Country, @Occupation, @Nationality, @TelNo, @FaxNo, @EmailAdd, @Password, @OnMailingList)DECLARE @CustIDent intSET @CustIDent = @@Identity INSERT INTO tblOrderDet(CustomerID, CollectionDate, ReturnDate, CollectionLocationID, ReturnLocationID, VehicleID, DeliveryAddress, FlightDetails, AdditionalInfo, NumberOfDrivers, CSANumber, CSBNumber, CSCNumber, CSDNumber, VehicleDailyRate, VehicleTotalCost, TotalHireCost)VALUES(@CustIdent, @CollectionDate, @ReturnDate, @CollectionLocationID, @ReturnLocationID, @VehicleID, @DeliveryAddress, @FlightNumber, @AdditionalInfo, @NumberOfDrivers, @CSANumber, @CSBNumber, @CSCNumber, @CSDNumber, @VehicleDailyRate, @VehicleTotalCost, @TotalHireCost)GOI will keep searching for answers on what I am doing wrong (don't like to be lazy!!) but if anyone can see anything noobishly silly that I am doing please help!!thanks a lot!Wisest is he who knows he does not know |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2004-12-21 : 16:23:26
|
| I suspect that the issue lies in how you are calling this sproc. When do you see the error? When creating? On execution?HTH=================================================================Sometimes I wonder whether the world is being run by smart people who are putting us on or by imbeciles who really mean it. -Mark Twain, author and humorist (1835-1910) |
 |
|
|
Fearless_Shultz
Starting Member
6 Posts |
Posted - 2004-12-21 : 16:30:52
|
| Sorry not to be more specific, I am using C# in an ASP.NET project. I see this error after calling the following function. public static void funcRegisterNewAndBook(string strFName, string strSName, int intAge, string strOccupation, string strAdd1, string strAdd2, string strAdd3, string strPostCode, string strCity, string strCountry, string strNationality, string strTelNo, string strFaxNo, string strEmailAdd, string strPassword, string strOnMailingList, DateTime dtCollectionDate, DateTime dtReturnDate, int intCollectionLocationID, int intReturnLocationID, string strVehicleID, string strDeliveryAddress, string strFlightNumber, string strAdditionalInfo, int intNumberOfDrivers, int intCSANumber, int intCSBNumber, int intCSCNumber, int intCSDNumber, decimal decVehicleDailyRate, decimal decVehicleTotalCost, decimal decTotalCost) { SqlConnection oConn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]); try { oConn.Open(); SqlCommand getData = new SqlCommand("sproc_NewUserHire", oConn); getData.CommandType = CommandType.StoredProcedure; getData.Parameters.Add("@FName", SqlDbType.VarChar).Value = strFName; getData.Parameters.Add("@SName", SqlDbType.VarChar).Value = strSName; getData.Parameters.Add("@Age", SqlDbType.Int).Value = intAge; getData.Parameters.Add("@Occupation", SqlDbType.VarChar).Value = strOccupation; getData.Parameters.Add("@Add1", SqlDbType.VarChar).Value = strAdd1; getData.Parameters.Add("@Add2", SqlDbType.VarChar).Value = strAdd2; getData.Parameters.Add("@Add3", SqlDbType.VarChar).Value = strAdd3; getData.Parameters.Add("@PostCode", SqlDbType.VarChar).Value = strPostCode; getData.Parameters.Add("@City", SqlDbType.VarChar).Value = strCity; getData.Parameters.Add("@Country", SqlDbType.VarChar).Value = strCountry; getData.Parameters.Add("@Nationality", SqlDbType.VarChar).Value = strNationality; getData.Parameters.Add("@TelNo", SqlDbType.VarChar).Value = strTelNo; getData.Parameters.Add("@FaxNo", SqlDbType.VarChar).Value = strFaxNo; getData.Parameters.Add("@EmailAdd", SqlDbType.VarChar).Value = strEmailAdd; getData.Parameters.Add("@Password", SqlDbType.VarChar).Value = strPassword; getData.Parameters.Add("@OnMailingList", SqlDbType.VarChar).Value = strOnMailingList; getData.Parameters.Add("@CollectionDate", SqlDbType.DateTime).Value = dtCollectionDate; getData.Parameters.Add("@ReturnDate", SqlDbType.DateTime).Value = dtReturnDate; getData.Parameters.Add("@CollectionLocationID", SqlDbType.Int).Value = intCollectionLocationID; getData.Parameters.Add("@ReturnLocationID", SqlDbType.Int).Value = intReturnLocationID; getData.Parameters.Add("@VehicleID", SqlDbType.VarChar).Value = strVehicleID; getData.Parameters.Add("@DeliveryAddress", SqlDbType.VarChar).Value = strDeliveryAddress; getData.Parameters.Add("@FlightNumber", SqlDbType.VarChar).Value = strFlightNumber; getData.Parameters.Add("@AdditionalInfo", SqlDbType.VarChar).Value = strAdditionalInfo; getData.Parameters.Add("@NumberOfDrivers", SqlDbType.Int).Value = intNumberOfDrivers; getData.Parameters.Add("@CSANumber", SqlDbType.Int).Value = intCSANumber; getData.Parameters.Add("@CSBNumber", SqlDbType.Int).Value = intCSBNumber; getData.Parameters.Add("@CSCNumber", SqlDbType.Int).Value = intCSCNumber; getData.Parameters.Add("@CSDNumber", SqlDbType.Int).Value = intCSDNumber; getData.Parameters.Add("@VehicleDailyRate", SqlDbType.Money).Value = decVehicleDailyRate; getData.Parameters.Add("@VehicleDailyRate", SqlDbType.Money).Value = decVehicleDailyRate; getData.Parameters.Add("@VehicleTotalCost", SqlDbType.Money).Value = decVehicleTotalCost; getData.Parameters.Add("@TotalHireCost", SqlDbType.Money).Value = decTotalCost; getData.ExecuteNonQuery(); } finally { oConn.Close(); } } Wisest is he who knows he does not know |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-12-21 : 16:34:40
|
| So did you count up the number of inputs in the stored procedure and compare that to how many arguments you are passing in from C#?Tara |
 |
|
|
Fearless_Shultz
Starting Member
6 Posts |
Posted - 2004-12-21 : 16:59:10
|
| I did now! Thanks Tara I was looking for something more complex than!!! /me cowers in the shame corner for a whileWisest is he who knows he does not know |
 |
|
|
Fearless_Shultz
Starting Member
6 Posts |
Posted - 2004-12-21 : 17:20:43
|
| Just a quick follow-upI have now gone through my code again a few times and realised that I had made a couple of silly typos which were stopping my code working and really didn't deserve being posted onto a help forum....The moral of "thoroughly check your code before going looking for help" is duly noted!!!!thanks for the help and not resorting to all out verbal abuse guys!!Wisest is he who knows he does not know |
 |
|
|
|
|
|