Stored Prosedure Dont Working

Apr 25, 2008

i have 2 server, Database Server and Application Server.

i create a stored prosedure in Database SERVER (sql 2005)

i call this stored prosedure from my application but , my application dont see my stored prosedure..

what is a problem ? this is working my local computer and database.

my stored prosedure : sp_MyStoredProsedure

application :

...........Using myConnection As New SqlConnection(Config.ConnectionString)Dim myCommand As SqlCommand = New SqlCommand("sp_MyStoredProsedure", myConnection)

myCommand.CommandType = CommandType.StoredProcedure

......

i think Ado.net permission problem but i dont know what is problem

thx.

View 6 Replies


ADVERTISEMENT

Stored Prosedure

Jul 28, 2007

Hello Dears,
I need to make an stored procedure with two parameter the first patameter will take the you birthdate and the second
will take the the the date for now and this sp will calculate your age

how can i do this
anyone will help i will greetful

with my best regard
khalil .T.Hamad

View 5 Replies View Related

How To Fetch Value That Is Returened By Stored Prosedure ???...

Jul 13, 2007

I am inserting value in the database with identity column, but I want to know the identity column value that is inserted by this command. I don't want to use any additional query to fetch this value, so I have created a stored Prosedure that Inserts value with identity column in the database and also returns last identity column value.
But i don't know how to fetch this value in ASP.Net, because ExecuteNonQuery() is used for INSERT,UPDATE and DELETE only, bu using this method my half of need will be completed (that is insertion) but how i fetch returned value.
I am putting table and Stored Prosedure, pls reply me how i get returned value.
 --following is my emp table
create table emp
(
EID int identity(1,1),
EName varchar(50)
)
--following is my stored prosedure

create proc ReturnID @ename varchar(50)
as
insert into emp values(@ename)
begin tran
declare @err int
set @err = @@ERROR
if @err <> 0
return select max(eid) from emp
commit tran


--following command insert value in database and returns last ID
ReturnID jasim

 
Pls reply me with proper solutions.

View 2 Replies View Related

Calling A Stored Procedure From ADO.NET 2.0-VB 2005 Express: Working With SELECT Statements In The Stored Procedure-4 Errors?

Mar 3, 2008

Hi all,

I have 2 sets of sql code in my SQL Server Management Stidio Express (SSMSE):

(1) /////--spTopSixAnalytes.sql--///

USE ssmsExpressDB

GO

CREATE Procedure [dbo].[spTopSixAnalytes]

AS

SET ROWCOUNT 6

SELECT Labtests.Result AS TopSixAnalytes, LabTests.Unit, LabTests.AnalyteName

FROM LabTests

ORDER BY LabTests.Result DESC

GO


(2) /////--spTopSixAnalytesEXEC.sql--//////////////


USE ssmsExpressDB

GO
EXEC spTopSixAnalytes
GO

I executed them and got the following results in SSMSE:
TopSixAnalytes Unit AnalyteName
1 222.10 ug/Kg Acetone
2 220.30 ug/Kg Acetone
3 211.90 ug/Kg Acetone
4 140.30 ug/L Acetone
5 120.70 ug/L Acetone
6 90.70 ug/L Acetone
/////////////////////////////////////////////////////////////////////////////////////////////
Now, I try to use this Stored Procedure in my ADO.NET-VB 2005 Express programming:
//////////////////--spTopSixAnalytes.vb--///////////

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim sqlConnection As SqlConnection = New SqlConnection("Data Source = .SQLEXPRESS; Integrated Security = SSPI; Initial Catalog = ssmsExpressDB;")

Dim sqlDataAdapter As SqlDataAdapter = New SqlDataAdaptor("[spTopSixAnalytes]", sqlConnection)

sqlDataAdapter.SelectCommand.Command.Type = CommandType.StoredProcedure

'Pass the name of the DataSet through the overloaded contructor

'of the DataSet class.

Dim dataSet As DataSet ("ssmsExpressDB")

sqlConnection.Open()

sqlDataAdapter.Fill(DataSet)

sqlConnection.Close()

End Sub

End Class
///////////////////////////////////////////////////////////////////////////////////////////

I executed the above code and I got the following 4 errors:
Error #1: Type 'SqlConnection' is not defined (in Form1.vb)
Error #2: Type 'SqlDataAdapter' is not defined (in Form1.vb)
Error #3: Array bounds cannot appear in type specifiers (in Form1.vb)
Error #4: 'DataSet' is not a type and cannot be used as an expression (in Form1)

Please help and advise.

Thanks in advance,
Scott Chang

More Information for you to know:
I have the "ssmsExpressDB" database in the Database Expolorer of VB 2005 Express. But I do not know how to get the SqlConnection and the SqlDataAdapter into the Form1. I do not know how to get the Fill Method implemented properly.
I try to learn "Working with SELECT Statement in a Stored Procedure" for printing the 6 rows that are selected - they are not parameterized.




View 11 Replies View Related

Dont Getting Error

Oct 2, 2007

update [order]

set Status = 'Open'
from (select [order].OrderId from CRM_Order [order]

inner join crm_orderproduct Oproduct on Oproduct.OrderId=[order].OrderId

group By [order].OrderId

having count(Oproduct.OrderProductId)=0 )



I m trying to update the Order <Table> Field Status, where order products count is zero. The Select statement lonely working fine but in update statement getting error.


Msg 102, Level 15, State 1, Line 6

Incorrect syntax near ')'.

View 4 Replies View Related

Conversation That Dont End.

Oct 16, 2006

Hi There

Message ordering is of utmost importance in our application.

As i found in testing the only way to ensure message ordering is if they are in the same conversation.If you send multiple messages in different conversations there is no garantee which will be processed first.

Therefore i will be creating conversations that last "forever", that is using a single conversation.

I plan on doing a BEGIN DIALOG CONVERSATION when an inititator site is setup and writing the conversation handle guid to a table.

I will them simply SEND ON SONVERSATION using the guid, i will never issue a end conversation from target or initiator.

Is this theory solid, ie: is there a better way or best practice to do this?

I know that conversatons persist with sql server restarts, however what happens if an initiator site db is restored ?

I was thinking of adding logic to first check if a conversation endpoint exists with the specified guid if not , then start another conversation. But is this the best way?

Thanx

View 2 Replies View Related

Dont Display Address If Its Not There!

Jul 28, 2007

hi there, i have a invoice template that when printed has a box for the users address (which there always will be) and a box for their delivery address if they are having the items delivered. However sometimes they dont have things delivered and so the record in the delivery table does not exist. In this case it will throw an error, how can i avoid this. the code im using i have posted below string sql = "SELECT [del_address], [del_post_code], [del_date], [del_time] From tbl_del WHERE order_ID = " + intOrderID;
 
 
//This creates a sql command which executes the sql statement.SqlCommand sqlCmd = new SqlCommand(sql, myConn);
myConn.Open();SqlDataReader dr = sqlCmd.ExecuteReader();
//This reads the first result from the sqlReader
dr.Read();
try
{
 
 
//string strDel_Address = dr["del_address"].ToString();
 if (Convert.ToString(dr["del_charge"].ToString()) != null)
{
//delivery items lblDelAddy.Text = dr["del_address"].ToString();
lblDelPCode.Text = dr["del_post_code"].ToString();
 

View 3 Replies View Related

Dont Know Which Database To Use For The Following Site

Jul 18, 2007

Hi All,Just wondered if i could ask you for some advice and help.I'm looking to write a site, and one of the functions of the site is to remind the user of a certain event at a certain time. I was wondering how i would do this? or if anyone has a working example i could use?Also I dont quite know what database to use...... would MySQL do the function i am after???? If so then no more problem lol If not what database would you recommend i use?ThanksDanny

View 4 Replies View Related

Dont Undertsand This Error

Aug 10, 2006

Hi all, can anyone explain to me why i am getting this error:

Cannot insert the value NULL into column 'WORKPATTERN_END', table 'MockDownload_V52.dbo.EMPLOYEE_WORKPATTERN'; column does not allow nulls. INSERT fails.

The code i am using is:



DELETE EMPLOYEE_WORKPATTERN
INSERT INTO EMPLOYEE_WORKPATTERN(
EMPLOY_REF)
SELECT CAST(EMPLOY_REF AS VARCHAR(10))
FROM EMPLOYEE

View 10 Replies View Related

Find A Table When We Dont Know In Which DB It Is

Nov 14, 2006

Hi Friends,
is it possible to find a table in which database it is?
ex: i have one table name rider. i've created it in one database, but i dont know in which database it is.but i know the server name.

is it possible to find like this?


thank you very much.

Vinod

View 9 Replies View Related

If The Value Is 'null 'dont Update Anything

Nov 7, 2007

Hi.I have a update query:

UPDATE test1
SET testprice= ((unitprice*8)/100) + unitprice

it's good.but I dont want to change the testprice if the unitprice is NULL.what should I do?

View 2 Replies View Related

Dont Drop And Delete

Dec 10, 2007

Hi!

I've one table named mytable. I dont want to drop and delete
this table? How can i achieve this ?
Please help me out!

Thanks!

View 9 Replies View Related

Why Dont My Question Pic Up 2 Rows?

Jul 5, 2007

Hi


I have a very smal question that im doing with the query builder in visual studio .net 2005.

there i have this sql question



SELECT tblObjekt.ObjektArkivID, tblObjekt.KundID, tblObjekt.KundensArkivNummer, tblObjekt.HuvudTitel, tbl_Spar.SparID
FROM tblObjekt INNER JOIN
tbl_Spar ON tblObjekt.ObjektArkivID = tbl_Spar.ObjektArkivID.



The problem i have is that it only finds 9 of 11 rows in the database. I thought that maybe some field were "null" but every field has some text in it.

The query must work since it finds 9 items, but 2 are missing.
Someone that knows what can be wrong?

Best regards / Mitmit

View 2 Replies View Related

Dont Sum Duplicate Entries

Jan 2, 2008



Hi.
I have a table with Login and Logoff Time of users, but there could be duplicate Logtimes in the dataset, but for
different products. Because of this I cant do a distinct in the dataset. I need the Product and some other details in my Report.

I tried to make two datasets. One for the Select distinct and one for the other.

But the Problem is:
in my report, I need a table, where I make the Sum of the Logintime a day and in another column I calculate with data from the other dataset.(Logtime + data from dataset2). But this doesnt work, so I think, that is it not possible to join 2 dataset in one table.

datetime Login | datetime Logout | Product
11.12.2007 10:15 | 11.12.2007 12:15 | p1
11.12.2007 10:15 | 11.12.2007 12:15 | p2
11.12.2007 12:19 | 11.12.2007 15:15 | p2

Is there another option I can do this?



View 4 Replies View Related

Item And Partern From T1 That Dont Exist In T2

May 12, 2006

t1
item
partner


t2
item
partner
fname
store

i like select item and partern from t1 that dont exist in t2

View 1 Replies View Related

Manual SQl Dont Work Correctly

Nov 10, 2007

Hello All Prg's
I need your help,
I use Database SQL server Express with C#
when I entred some data into DB by clciking on the table in server Explorer in Visual Studio 2005 IDE,
and then I make SQL in the code
as:
if (e.KeyCode == Keys.Return)
{
bool res;
int OldPlayerId = 0;
string ConnectionStr = Program.Member_Connect;
string sqlQuery = "select Player_ID from Player where Player_Code = '" + textBox1.Text + "'";
SqlConnection Sql_connection = new SqlConnection(ConnectionStr);
Sql_connection.Open();
SqlCommand command = new SqlCommand(sqlQuery, Sql_connection);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.HasRows)
{
if (dataReader.Read())
OldPlayerId = dataReader.GetInt32(0);
else
MessageBox.Show("rtet");
}
else
{
res = false;
}
comboBox2.SelectedValue = textBox1.Text;
command.Dispose();
Sql_connection.Close();
Sql_connection.Dispose();
comboBox1.SelectedValue = OldPlayerId;
}
it work correctly on the old data that I entred them manualy, but when I enter new data from my project, this query don't give correct value, it still work correctly on old data,

I tried to take same data by combobox connected to view that contain same sql ,it work always.
but I need manualy Sql.
Please help me , I am very lating to delever my project...
please help me
thank you very mush

View 13 Replies View Related

I Dont Have Any Backup Of My Database, But I Have The Mdf's And Ldf's Files

Jul 23, 2005

Im trying to recover my database using the mdf and ldf files.I dont have any backup and i have recovered two of the mdf files usinga tool which "discovers" deleted files after hard drive formatting...It sounds cool, isnt it...:? :(Obviously, i get a "suspect" message when the server starts and the logfile says this kind of things:ˇ"Full PathName.MDF is not a primary database file." (This is one ofthe files repaired using the magic tool.ˇError: 823, Severity: 24, State: 6ˇ"I/O error (torn page) detected during read at offset0000000000000000 in file 'Full PathiName2.mdf'... Name2.mdf is thesecond fileˇDevice activation error. The physical file name 'Full PathName2.mdf'may be incorrect.When i try to execute the command "DBCC CHECKDB ('Database_Name') WITHPHYSICAL_ONLY" i get the following message :ˇCould not open FCB for invalid file ID 0 in database 'Logs'.Do you have any ideas? Thank you very much...:D

View 2 Replies View Related

Help Stored Procedure Working But Not Doing Anything

Jul 31, 2006

Help Stored procedure working but not doing anything New Post
Quote    Reply
Please i need some help.

I am calling a stored procedure from  asp.net and there is a
cursor in the stored procedure that does some processing on serval
tables.

if i run the stored procedure on Query Analyzer it works and does what
it is suppose to do but if i run it from my asp.net/module control it
goes. acts likes it worked but it does not do what is suppose to do.
i believe the cursor in the stroed procedure does not run where is
called programmatically from the asp.net/module control page.plus it
does not throw any errors


This is the code from my control
System.Data.SqlClient.SqlParameter [] param={new
System.Data.SqlClient.SqlParameter("@periodStart",Convert.ToDateTime(startDate)),new
System.Data.SqlClient.SqlParameter("@periodStart",Convert.ToDateTime(endDate)),new
System.Data.SqlClient.SqlParameter("@addedby",UserInfo.FullName+ "
"+UserInfo.Username)};
               
string
str=System.Configuration.ConfigurationSettings.AppSettings["payrollDS"];
               
System.Data.SqlClient.SqlConnection cn=new
System.Data.SqlClient.SqlConnection(str);
               
cn.Open();              

               
//System.Data.SqlClient.SqlTransaction trans=cn.BeginTransaction();

               
SqlHelper.ExecuteScalar(cn,System.Data.CommandType.StoredProcedure,"generatePaylistTuned",param);
      


------------------------THis is the code for my storedprocedure-------------

CREATE PROCEDURE [dbo].[generatePaylistTuned]
@periodStart datetime,
@periodEnd datetime,
@addedby varchar(40)

AS

begin transaction generatePayList

DECLARE @pensioner_id int, @dateadded datetime,
 @amountpaid float,
@currentMonthlypension float,@actionType varchar(50),
@isAlive bit,@isActive bit,@message varchar(80),@NoOfLoadedPensioners int,
@NoOfDeadPensioners int,@NoOfEnrolledPensioners int,@DeactivatedPensioners int,
@reportSummary varchar(500)

set @NoOfLoadedPensioners =0

set @NoOfDeadPensioners=0
set @NoOfEnrolledPensioners=0
set @DeactivatedPensioners=0
set @actionType ="PayList Generation"

DECLARE paylist_cursor CURSOR FORWARD_ONLY READ_ONLY FOR

select p.pensionerId,p.isAlive,p.isActive,py.currentMonthlypension
from pensioner p left outer join pensionpaypoint py on  p.pensionerid=py.pensionerId

where p.isActive = 1


OPEN paylist_cursor

FETCH NEXT FROM paylist_cursor
INTO @pensioner_id,@isAlive,@isActive,@currentMonthlypension

WHILE @@FETCH_STATUS = 0
BEGIN

set @NoOfLoadedPensioners=@NoOfLoadedPensioners+1
if(@isAlive=0)
begin
update Pensioner
set isActive=0
where pensionerid=@pensioner_id
set @DeactivatedPensioners =@@ROWCOUNT+@DeactivatedPensioners
set @NoOfDeadPensioners =@@ROWCOUNT+@NoOfDeadPensioners
end
else
begin
insert into pensionpaylist(pensionerId,dateAdded,addedBy,
periodStart,periodEnd,amountPaid)
values(@pensioner_id,getDate(),@addedby, @periodStart, @periodEnd,@currentMonthlypension)
set @NoOfEnrolledPensioners =@@ROWCOUNT+ @NoOfEnrolledPensioners
end

   -- Get the next author.
   FETCH NEXT FROM paylist_cursor
   INTO  @pensioner_id,@isAlive,@isActive,@currentMonthlypension
END

CLOSE paylist_cursor
DEALLOCATE paylist_cursor

set @reportSummary ="The No. of Pensioners Loaded:
"+Convert(varchar,@NoOfLoadedPensioners)+"<BR>"+"The No. Of
Deactivated Pensioners:
"+Convert(varchar,@DeactivatedPensioners)+"<BR>"+"The No. of
Enrolled Pensioners:
"+Convert(varchar,@NoOfEnrolledPensioners)+"<BR>"+"No Of Dead
Pensioner from Pensioners Loaded: "+Convert(varchar,@NoOfDeadPensioners)
insert into reportSummary(dateAdded,hasExceptions,periodStart,periodEnd,reportSummary,actionType)
values(getDate(),0, @periodStart, @periodEnd,@reportSummary,'Pay List Generation')

 if (@@ERROR <> 0)               
          BEGIN

insert into reportSummary(dateAdded,hasExceptions,periodStart,periodEnd,reportSummary,actionType)
values(getDate(),1, @periodStart,@periodEnd,@reportSummary,'Pay List Generation')

ROLLBACK TRANSACTION  generatePayList

          END

commit Transaction generatePayList
GO

View 5 Replies View Related

Stored Proc Not Working, HELP PLEASE!

May 9, 2005

I'm pretty new when it comes to Stored Procs, and for some reason, the CurAge isn't coming up with an actual numeric value. Does anyone see what I am doing wrong?

CREATE PROCEDURE sp_GetTargetProducts
@hmid int,
@wtid int
AS
DECLARE @CurAge INT
if exists(
SELECT LastName, FirstName, HMID, DATEDIFF (YY , BirthDate, GetDate()) As CurAge
FROM Members
WHERE hmid = @hmid
)
BEGIN
SELECT DISTINCT Product, ProductAdvance, AgeBottom, AgeTop, ProductName, ProductDesc, ProductPrice, ProductPicture
FROM Products
WHERE wtid = @wtid
AND AgeBottom <= @CurAge
AND AgeTop >= @CurAge
GROUP BY Product, ProductAdvance, AgeBottom, AgeTop, ProductName, ProductDesc, ProductPrice, ProductPicture
return(1)
END
else
return(0)
GO

View 6 Replies View Related

Dont Know About Database Level Locking Scheme

Apr 20, 2007

I m using sql server 2005
i have got one request ,to apply page level locking on database
can nyone how it is done
i can do that for a single script and for session(transaction isolation level)
but dont know about database level locking scheme

thanks in advance

View 2 Replies View Related

Dont Backup If Database Hasnt Changed

Sep 15, 2005

I do weekly full backups of my SQL databases via a scheduled T-SQL job.I noticed that I have some static databases that dont normally change,so I dont want to back it up if it has not changed, but when it does,then I want a backup.Is there something in the master table, as example, that I can checkprior to running the backup that will indicate any changes?An example is the Northwind database. I could exclude it from thebackup, but then I would not back it up if it where to change. Againthis is an example, I would not need to modify Northwind.Thanks in advance for any ideas; they usually give me ideas to problemsyet to come....Rob Camarda

View 3 Replies View Related

SqlParameters Not Working With Stored Procedures

Dec 31, 2006

Anyone can help me why is this not working?
My function is
public void updateSupplierInformation(string FirstLetter, string Vendor, string SegmentTeam, string VendorRank, string ScrubOwner)
{
SqlCommand myCommand = new SqlCommand("sp_LAST_UpdateSupplier", myConnection);
 
myCommand.CommandType = CommandType.StoredProcedure;
myConnection.Open();
SqlParameter myParam;
myParam = myCommand.Parameters.Add(new SqlParameter("@FirstLetterS", SqlDbType.VarChar, 1));
myParam.Direction = ParameterDirection.Input;
myParam.Value = FirstLetter;
myParam = myCommand.Parameters.Add(new SqlParameter("@VendorS", SqlDbType.VarChar, 30));
myParam.Direction = ParameterDirection.Input;
myParam.Value = Vendor;
myParam = myCommand.Parameters.Add(new SqlParameter("@SegTeamS", SqlDbType.VarChar, 30));
myParam.Direction = ParameterDirection.Input;
myParam.Value = SegmentTeam;
myParam = myCommand.Parameters.Add(new SqlParameter("@VendorRankS", SqlDbType.VarChar, 30));
myParam.Direction = ParameterDirection.Input;
myParam.Value = VendorRank;
myParam = myCommand.Parameters.Add(new SqlParameter("@ScrubOwnerS", SqlDbType.VarChar, 30));
myParam.Direction = ParameterDirection.Input;
myParam.Value = ScrubOwner;
 
int i =myCommand.ExecuteNonQuery();
 
myConnection.Close();
}
My Stored procedure is:
ALTER PROCEDURE sp_LAST_UpdateSupplier
@FirstLetterS varchar(1),
@VendorS varchar(30),
@SegTeamS varchar(30),
@VendorRankS varchar(30),
@ScrubOwnerS varchar(30)
AS
UPDATE [gntm_user].LAST_Supplier_Ownership
SET First_Letter =@FirstLetterS,Seg_Team =@SegTeamS,Vendor_Rank =@VendorRankS,
Scrub_Owner =@ScrubOwnerS
WHERE Vendor=@VendorS
 
RETURN
 
When I debug on any of the myParam value it displays "@FirstLetterS,@VendorS" etc. not the value which is being passed in the function which is FirstLetter,Vendor.
Can anyone help me on this please? Thanks in advance

View 2 Replies View Related

Working Woth Stored Procedures

May 6, 2007

Hi,
I am working on VS 2005 and I am using the grid view with Stored procedure the case is ..I want the grid to view all the supplier records by default .. but if the user specified a supplier name and/or type the grid should onlyview the relevant records..
What i did is .. I have created a text box (to enter the supplier name) and a drop down list (to choose the type)
** The problem is the grid does not appear unless I choose and fill the text box and drop down list and it only works with the type notwith the name ((does not match both parameters))
Can you please help I am stuck !!--------------------------------
My procedure is as following:
ALTER PROCEDURE p_test
@SupName nvarchar(200)='',@TypeID int= 0
AS
declare @SQL_Text varchar(8000)set @SQL_text = 'select * from dbo.v_supplier' +' where 1 = 1'
if rtrim(ltrim(@SupName)) <> ''set @SQL_Text = @sql_text + ' and name = '''+ @SupName +''''
if @TypeID <> ''set @SQL_Text = @sql_text + ' and type_id = '+ CONVERT(varchar, @TypeID)
if CONVERT(varchar, @TypeID)= '0'set @SQL_Text = @sql_text
BEGIN
exec(@sql_text)
END
----------------------------------------
My grid parameters is as following:
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSourceSup"></asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceSup" runat="server" ConnectionString="<%$ ConnectionStrings:con %>" SelectCommand="p_test" SelectCommandType="StoredProcedure">
<SelectParameters><asp:ControlParameter ControlID="txtSup" Name="SupName" PropertyName="Text" Type="String" DefaultValue="" /><asp:ControlParameter ControlID="drpType" Name="TypeID" PropertyName="SelectedValue" DefaultValue = 0 Type="Int32" /></SelectParameters>
</asp:SqlDataSource>

View 4 Replies View Related

Set Identity Not Working For Stored Procedure

Jan 31, 2008

Hi can someone tell me whats wrong with this stored procedure. All im trying to do is get the publicationID from the publication table in order to use it for an insert statement into another table. The second table PublicaitonFile has the publicaitonID as a foriegn key.
Stored procedure error: cannot insert null into column publicationID, table PublicationFile - its obviously not getting the ID.
ALTER PROCEDURE dbo.StoredProcedureUpdateDocLocField
@publicationID Int=null,@title nvarchar(MAX)=null,@filePath nvarchar(MAX)=null
ASBEGINSET NOCOUNT ON
IF EXISTS (SELECT * FROM Publication WHERE title = @title)SELECT @publicationID = (SELECT publicationID FROM Publication WHERE title = @title)SET @publicationID = @@IDENTITYEND
IF NOT EXISTS(SELECT * FROM PublicationFiles WHERE publicationID = @publicationID)BEGININSERT INTO PublicationFile (publicationID, filePath)VALUES (@publicationID, @filePath)END
 

View 5 Replies View Related

Update Stored Proc Not Working

Jan 12, 2005

I'm trying to run a UPDATE stored proc to allow my users to update records that are in a datagrid. What the update proc looks like is as follows:

Proc sp_UpdateRecords
@fname nvarchar(30), @lname nvarchar(30), @address1 nvarchar(50), @address2 nvarchar(50), @CITY nvarchar(33), @ST nvarchar(10), @ZIP_OUT nvarchar(5), @ZIP4_OUT nvarchar(4), @home_phone nvarchar(22), @autonumber int
AS
UPDATE NCOA20040603 SET fname=@fname, lname=@lname, address1=@address1, address2=@address2, CITY=@CITY, ST=@ST, ZIP_OUT=@ZIP_OUT, ZIP4_OUT=@ZIP4_OUT, home_phone=@home_phone
WHERE autonumber=@autonumber

The message I'm getting is as follows:

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index


What could be the problem

Any ideas are appriciated -- Thanks in advance
RB

View 5 Replies View Related

Working With Images In Stored Procs

Jan 17, 2005

What is the best way to store images in sql server and then retrieve them with stored proc's using vb.net/asp.net? There seems to be a lot of different opinions about just saving the img tag, the path, etc.

I only need to store 15 icons....

appreciate any help I can get.

Thanks

soggy coder seattle

View 4 Replies View Related

Stored Procedure - Insert Not Working

Jun 23, 2005

Having a little trouble not seeing why this insert is not happening.... --snip--  DECLARE c_studId CURSOR FOR  SELECT studentId  FROM students FOR READ ONLY   OPEN c_studId  FETCH NEXT FROM c_studId INTO @studentId  IF( @@FETCH_STATUS = 0 )  BEGIN   SET @studRec = 'Found'  END CLOSE c_studId DEALLOCATE c_studId
 BEGIN TRAN IF (@studRec <> 'Found')  BEGIN  INSERT INTO students  (studentId)  VALUES  (@studentId)    END  Well, you get the idea, and I snipped a lot of it.Why is it not inserting if the user is not found?Thanks all,Zath

View 6 Replies View Related

Simple Stored Procedure Not Working

Jul 14, 2005

I have a SP below that authenticates users, the problem I have is that activate is of type BIT and I can set it to 1 or 0.
If I set it to 0 which is disabled, the user can still login.
Therefore I want users that have activate as 1 to be able to login and users with activate as 0 not to login

 what are mine doing wrong ?

Please help


CREATE PROCEDURE DBAuthenticate

(
  @username Varchar( 100 ),
  @password Varchar( 100 )
)
As

DECLARE @ID INT
DECLARE @actualPassword Varchar( 100 )

SELECT
  @ID = IdentityCol,
  @actualPassword = password
  FROM CandidatesAccount
  WHERE username = @username and Activate = 1

IF @ID IS NOT NULL
  IF @password = @actualPassword
    RETURN @ID
  ELSE
    RETURN - 2
ELSE
  RETURN - 1
GO

View 5 Replies View Related

Stored Procedure Stops Working

Jun 1, 1999

I have a stored procedure which does a simple select joining 3 tables.

This had been working fine for weeks and then just stopped returning any rows even though data existed for it to return.

After re-compiling the procedure, it worked fine as before.

Does anyone know of any reason why a procedure would need recompiling like this?

We have been doing data restores and also dropping/recreating tables during this development. Would any of this affect a procedure?

View 3 Replies View Related

Why Isnt My Stored Procedure Working

Oct 24, 2007

Hi there below is my code for a sproc. however when i run it, it doesnt seem to create a table











USE [dw_data]
GO
/****** Object: StoredProcedure [dbo].[usp_address] Script Date: 10/24/2007 15:33:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



CREATE PROC [dbo].[usp_address]
(
@TableType INT = null

)

AS

IF @TableType is NULL OR @TableType = 1

BEGIN

IF NOT EXISTS (SELECT 1 FROM [DW_BUILD].INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'address')

CREATE TABLE [dw_build].[dbo].[address] (
[_id] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[address_1] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[address_2] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[category] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[category_userno] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[county] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[created] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[creator] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[end_date] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[forename] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[notes] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[other_inv_link] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[out_of_district] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[packed_address] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[paf_ignore] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[paf_valid] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[patient] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[patient_date] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[pct_of_res] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[postcode] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[real_end_date] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[relationship] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[relationship_userno] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[surname] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[telephone] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[title] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[town] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[updated] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[updator] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

END

IF @TableType is NULL OR @TableType = 2

BEGIN

CREATE TABLE [dw_build].[dbo].[address_cl] (
[_id] [int] NULL,
[address_1] [varchar](40) NULL,
[address_2] [varchar](40) NULL,
[category] [varchar](7) NULL,
[category_userno] [int] NULL,
[county] [varchar](40) NULL,
[created] [datetime] NULL,
[creator] [int] NULL,
[end_date] [datetime] NULL,
[forename] [varchar](40) NULL,
[notes] [varchar](max) NULL,
[other_inv_link] [int] NULL,
[out_of_district] [bit] NOT NULL,
[packed_address] [varchar](220) NULL,
[paf_ignore] [bit] NOT NULL,
[paf_valid] [bit] NOT NULL,
[patient] [int] NULL,
[patient_date] [datetime] NULL,
[pct_of_res] [int] NULL,
[postcode] [varchar](40) NULL,
[real_end_date] [datetime] NULL,
[relationship] [varchar](7) NULL,
[relationship_userno] [int] NULL,
[surname] [varchar](40) NULL,
[telephone] [varchar](40) NULL,
[title] [varchar](40) NULL,
[town] [varchar](40) NULL,
[updated] [datetime] NULL,
[updator] [int] NULL
) ON [PRIMARY]

END

View 13 Replies View Related

Working With Results From A Stored Procedudure

Nov 2, 2007

I am working with a complex Stored Procedure which I need to be able to filter and sort by various criteria. Can I please ask how I can get the data that the SP returns into place that I can apply my search criteria?

Ive tried the code below in the SQL Query Analyzer but all I get is:
"Server: Msg 197, Level 15, State 1, Line 10
EXECUTE cannot be used as a source when inserting into a table variable."

DECLARE @TempPropLeads TABLE (
LeadNumber int,
LeadSource char(20) )

INSERT @TempPropLeads (LeadNumber, LeadSource)

EXEC dbo.usp_ReportProposalFromLead NULL ,'2004-06-01', '2004-06-02', NULL

SELECT *
FROM @TempPropLeads
ORDER BY LeadNumber DESC

GO
PS there are more fields returned from the SP - just using the above as a test.

Once I have got the data filtered/sorted as needed it's going to go into a Excel CSV spreadsheet

Cheers

View 7 Replies View Related

Stored Procedure Range Not Working

Dec 22, 2006

Hi All,I am trying to write a basic stored procedure to return a range ofvalues but admit that I am stumped. The procedure syntax used is:ALTER PROCEDURE Rpt_LegacyPurchaseOrderSp(@StartPoNumber PONumberType = 'Null',@FinishPoNumber PONumberType = 'Null')ASSET @StartPoNumber = 'PO_NUMBER_POMSTR'SET @FinishPoNumber = 'PO_NUMBER_POMSTR'SELECTIPPOMST_SID,--Start tbl_IPPOMSTPO_NUMBER_POMSTR,VENDOR_NUMBER_POMSTR,SHIP_NUMBER_POMSTR,CHANGE_ORDER_POMSTR,FOB_POINT_POMSTR,ROUTING_POMSTR,DATE_ISSUED_POMSTR,DATE_LAST_RECPT_POMSTR,CONTACT_PERSON_1_POMSTR,PREPAID_COLLECT_POMSTR,TERMS_POMSTR,AMOUNT_ESTIMATED_POMSTR,AMOUNT_RECEIVED_POMSTR,AMOUNT_PAID_POMSTR,LOCATION_CODE_POMSTR,SHIPPING_POINT_POMSTR,PRINT_IND_POMSTR,BUYER_POMSTR,SHIPMENT_POMSTR,STATUS_POMSTR,CURRENCY_POMSTR,CURRENCY_STATUS_POMSTR,AMOUNT_EST_CUR_POMSTR,AMOUNT_REC_CUR_POMSTR,AMOUNT_PAID_CUR_POMSTR,--Finish tbl_IPPOMSTIPPOITM_SID,--Start tbl_IPPOITMPO_NUMBER_POITEM,ITEM_NUMBER_POITEM,CATEGORY_POITEM,DESCRIPTION_POITEM,VENDOR_NUMBER_POITEM,DATE_ORIGINAL,DATE_RESCHEDULED,ACCOUNT_NUMBER_POITEM,STOCK_NUMBER_POITEM,JOB_NUMBER_POITEM,RELEASE_WO_POITEM,QUANTITY_ORDERED_POITEM,QUANTITY_RECVD_POITEM,UOM_POITEM,UNIT_WEIGHT_POITEM,UNIT_COST_POITEM,EXTENDED_TOTAL_POITEM,MATERIAL_NUMBER_POITEM,COMPLETE_POITEM,LOCATION_CODE_POITEM,INSPECTION_POITEM,BOM_ITEM_POITEM,COST_ACCOUNT_POITEM,CHANGE_ORDER_POITEM,TAX_CODE_POITEM,ISSUE_CODE_POITEM,QUANTITY_INSPECT_POITEM,EXC_RATE_CURR_POITEM,UNIT_COST_CURR_POITEM,EXTENDED_TOTAL_CURR_POITEM,PLANNER_POITEM,BUYER_POITEM--Finish tbl_IPPOITMIPVENDM_SID,--Start tbl_IPVENDMVENDOR_NUMBER_VENMSTR,VENDOR_NAME_VENMSTR,ADDRESS_LINE_1_VENMSTR,ADDRESS_LINE_2_VENMSTR,ADDRESS_LINE_3_VENMSTR,CITY_VENMSTR,STATE_VENMSTR,ZIP_CODE_VENMSTR,COUNTRY_VENMSTR--Finish tbl_IPVENDMFROM tbl_IPPOMSTJOIN tbl_IPPOITMON tbl_IPPOITM.PO_NUMBER_POITEM = tbl_IPPOMST.PO_NUMBER_POMSTRJOIN tbl_IPVENDMon tbl_IPVENDM.VENDOR_NUMBER_VENMSTR = tbl_IPPOMST.VENDOR_NUMBER_POMSTRWHERE tbl_IPPOMST.PO_NUMBER_POMSTR >= @StartPoNumber ANDtbl_IPPOMST.PO_NUMBER_POMSTR <= @FinishPoNumberBasically, no rows are returned for the valid (records in database)range I enter. I have been troubleshopoting the syntax. This hasinvolved commenting out references to @FinishPoNumber so in effect Ijust pass in a valid PO Number using @StartPoNumber parameter. Thisworks in terms of returning all 76545 PO records.Can anyone help me to identify why this syntax will not return a rangeof PO records that fall between @StartPoNumber and @FinishPoNumber?Any help would be greatly appreciated.Many Thanks*rohan* & Merry Christmas!

View 2 Replies View Related

Displaying The Values That Dont Match And Replacing By NULL

Feb 6, 2003

Hi,

Im having a couple of problems with SQL.

I have this query...

SELECT Band.Name, Member.Name
FROM Member
JOIN MemberOf ON Member.Mid = MemberOf.Mid
JOIN Band On MemberOf.Bid = Band.Bid
WHERE MemberOf.Instrument = 'keyboards';

which basically shows me the name of the bands who had keyboard players. I would like it to also display the names of the band who didnt have keyboard players, replacing the keyboard players name with "NULL".

so... my questions are :)

how do u get it to display the records that do not match the condition, and how do u get it to replace the keyboard players name with "NULL" when they do not match the condition.

PS. The three tables are

Band. Which has Bid as a primary key.
Member. Which has Mid as a primary key.
MemberOf. Which links these through its two foreign keys Mid and Bid.

Thanks for your help! (assuming someone does)

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved