Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADO Error. Invalid Object Name
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01437967
Message ID:
01437987
Vues:
42
Could it be that this SP is in different schema?

>Yes & No:
>
>When I run this in SQL:
>
>
>USE WorkIT
>declare @p1 bigint
>set @p1=NULL
>exec wit_AddAddress @AddressKey=@p1 output,@AddressTypeKey=456,@Street1=N'AAAAAAAAAAAAAA',@Street2=N'AAAAAAAAAAAAAAA',@City=N'AAAAAAAAAAAA',@State=N'AA',@PostalCode=N'AAAAA'
>select @p1
>
>
>
>I get the same error. Yet the sproc IS in the database.
>
>
>
>
>
>>Did you verify that this SP in in correct database? Did you try running it directly in SSMS?
>>
>>>I have a SQL stored proc called wit_AddAddress:
>>>
>>>
>>>CREATE PROCEDURE wit_AddAddress
>>>	@AddressTypeKey	INT,
>>>	@Street1	VARCHAR(100),
>>>	@Street2	VARCHAR(100),
>>>	@City		VARCHAR(40),
>>>	@State		CHAR(2),
>>>	@PostalCode	CHAR(10),
>>>	@AddressKey	INT = 0 OUTPUT
>>>AS
>>>
>>>BEGIN
>>>
>>>	INSERT INTO wit_AddAddress
>>>		(AddressTypeKey, Street1, Street2, City, State, PostalCode)
>>>		VALUES
>>>		(@AddressTypeKey, @Street1, @Street2, @City, @State, @PostalCode)
>>>		
>>>	SET @AddressKey = SCOPE_IDENTITY()	
>>>
>>>END
>>>
>>>
>>>I have verified that this proc is there in SQL. When I run the following C# code, I get the error "Invalid object name 'wit_AddAddress'":
>>>
>>>
>>>public override bool SaveChanges()
>>>{
>>>    bool RetVal = Validate();
>>>
>>>    if (RetVal)
>>>    {
>>>        string ProcName = string.Empty;
>>>
>>>        SqlParameter pAddressKey = new SqlParameter("@AddressKey", 0);
>>>
>>>        if (this.RecordId == 0)
>>>        {
>>>            pAddressKey.Direction = ParameterDirection.Output;
>>>            ProcName = "wit_AddAddress";
>>>        }
>>>        else
>>>        {
>>>
>>>            pAddressKey.Value = this.RecordId;
>>>            ProcName = "wit_UpdateAddress";
>>>        }
>>>       
>>>        SqlParameter pAddressTypeKey = new SqlParameter("@AddressTypeKey",_AddressTypeKey);
>>>        SqlParameter pStreet1 = new SqlParameter("@Street1", _Street1);
>>>        SqlParameter pStreet2 = new SqlParameter("@Street2", _Street2);
>>>        SqlParameter pCity = new SqlParameter("@City", _City);
>>>        SqlParameter pState = new SqlParameter("@State", _State);
>>>        SqlParameter pPostalCode = new SqlParameter("@PostalCode", _PostalCode);
>>>
>>>        ArrayList colParams = new ArrayList();
>>>        colParams.Add(pAddressKey);
>>>        colParams.Add(pAddressTypeKey);
>>>        colParams.Add(pStreet1);
>>>        colParams.Add(pStreet2);
>>>        colParams.Add(pCity);
>>>        colParams.Add(pState);
>>>        colParams.Add(pPostalCode);
>>>
>>>        AppDataAccess.ExecuteNonQuery(ProcName, colParams);
>>>
>>>        if (AppDataAccess.DataException == null)
>>>        {
>>>
>>>            if (pAddressKey.Direction == ParameterDirection.Output)
>>>            {
>>>                this.RecordId = Convert.ToInt32(pAddressKey.Value);
>>>            }
>>>        }
>>>        else
>>>        {
>>>            throw AppDataAccess.DataException;
>>>        }
>>>    }
>>>
>>>    return RetVal;
>>>}
>>>
>>>
>>>When called for edits, the reference to "wit_UpdateAddress" works. Like I said, the proc is there. Anyone know why this would be happening????
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform