Don't Know How To Get It Work With Stored Precedures

Sep 14, 2006

Wael writes "Hi all.
i am using SQL server 2000 database and crystal reports XI.
The purpose of this report is to measure the loyalty of the clients to buy and use a prepaid cards from a telephone company, the company concerned to know how it perform on a various range measures.
in technical saying. we have 2 tables (CLL, CRD) the first one save a record about each call made by a certain card, including card no, source no(very important), destination no , date performed, duration and so on ...
the second table contains information about card itself like card no, card price, type , pricing category, time open, date closed (very important), brand, and so on....
as i mentioned there is only 2 fields in concern in our report.
*the first is the source no as an indication of a client (assume that the client will always call from his home to outer line or whatever .... )
*the second is the date closed as it says that a certain card finishes its value at this date, it will be the base date to build your periods on.

the report should do the following:-
1- prompt the user for a period range to analyze.
2- prompt the user to specify how this range will be analyzed (yearly, quarterly, monthly, weekly, ....).
3- cut the range into slices as determined in the second period.
4- for each period, compare it with the previous periods (as whole from the start of the range to just before the current period) to get the following 3 counts:
- new clients : didn't call at the previous period but called in the current period.
- existing clients : called in previous period and still calling in the current period.
- left clients : called in previous period and didn't in the current period .
5- and so on till the last period in the range.
6- this data preferred to be displayed graphically, if not as a crosstab.
7- note that : i said certain client called in a certain period , if he used a card and call at least one time in a that period.

please know that i am a new bie in stored procedures, so if there is a possibility for that report to run with stored procedure, i will be grateful if it is in some details.
at the end , i am so sorry for that detailed explanation, but i want to clarify my poit. please any help, i will appreciate it.

thanks for your time."

View 1 Replies


ADVERTISEMENT

Transaction On Stored Precedures

Jul 20, 2005

Hi allquestion regarding how transactions work in SQL Server...stored procedure below that generates unique IDs for messages wesend to the backend It looks like sometimes, the number generated isidentical for a messages that were sent simultaneously. Since thisseems like a concurrency issue, am I correct in thinking that usingSQLtransactions within the stored procedure code will solve this problem?The stored procedure is outlined below, the code in red is what Ithink should go in to solve the concurrency problem.CREATE PROCEDURE [dbo].[praCCGetNewCDMIndex]@newdate intASSET NOCOUNT ONDECLARE @lastdate intDECLARE @lastindex intDECLARE @newindex intBEGIN TRAN CDMIndexSELECT @lastdate = N_JULIANDATE FROM tbl_CC_CDMIndexesSELECT @lastindex = N_INDEX FROM tbl_CC_CDMIndexesIF @lastdate = @newdateSET @newindex = @lastindex + 1ELSESET @newindex = 1UPDATE tbl_CC_CDMIndexesSET N_JULIANDATE = @newdate,N_INDEX = @newindexSELECT N_INDEX FROM tbl_CC_CDMIndexesCOMMIT TRAN CDMIndexSET NOCOUNT OFFGO

View 2 Replies View Related

Exec Stored Precedures On MSSQL2000 From Oracle

Jul 14, 2003

Hello,
Does anybody know, how can I execute stored procedures that are on MSSQL Server 2000 from Oracle9i SP ? Can you show me an examle ?

Thanks for any help.

View 3 Replies View Related

Stored Procedure Does Not Work

Nov 15, 2006

Hi All
Please review this vb6 code (the stored procedure was added by aspnet_regsql.exe)
Thanks
Guy 
 
   With CMD      .CommandText = "aspnet_Users_CreateUser"      Call .Parameters.Refresh      .Parameters(1).Value = "812cb465-c84b-4ac8-12a9-72c676dd1d65"      .Parameters(2).Value = "myuser"      .Parameters(3).Value = 0      .Parameters(4).Value = Now()      Call RS.Open(CMD)   End With
The error I get is :Invalid character value for cast specification.
This is the stored procedure code:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[aspnet_Users_CreateUser]
@ApplicationId uniqueidentifier,
@UserName nvarchar(256),
@IsUserAnonymous bit,
@LastActivityDate DATETIME,
@UserId uniqueidentifier OUTPUT
AS
BEGIN
IF( @UserId IS NULL )
SELECT @UserId = NEWID()
ELSE
BEGIN
IF( EXISTS( SELECT UserId FROM dbo.aspnet_Users
WHERE @UserId = UserId ) )
RETURN -1
END
INSERT dbo.aspnet_Users (ApplicationId, UserId, UserName, LoweredUserName, IsAnonymous, LastActivityDate)
VALUES (@ApplicationId, @UserId, @UserName, LOWER(@UserName), @IsUserAnonymous, @LastActivityDate)
RETURN 0
END
 
 

View 1 Replies View Related

Cannot Get Stored Procedure To Work

Dec 10, 2007

I am trying to pass a value from one stored procedure into another. I have got the following stored procedures:
Stored Procedure 1:ALTER PROCEDURE test2
(@Business_Name nvarchar(50)
)
AS
BEGINDECLARE @Client_ID INT
SET NOCOUNT ON;
INSERT INTO client_details(Business_Name) VALUES(@Business_Name) SELECT @Client_ID = scope_identity()
IF @@NESTLEVEL = 1
SET NOCOUNT OFF
 
RETURN @Client_ID
END
Stored Procedure 2 - Taking Client_ID from the proecedure test2ALTER PROCEDURE dbo.test3
(
@AddressLine1 varchar(MAX),
@Client_ID INT OUTPUT
)
ASDECLARE @NewClient_ID INT
EXEC test2 @Client_ID = @NewClient_ID OUTPUT
INSERT INTO client_premises_address(Client_ID, AddressLine1) VALUES(@Client_ID, @AddressLine1)
SELECT @NewClient_ID
When I run this proecedure I get the following error:
FailedProcedure or function 'test2' expects parameter '@Business_Name', which was not supplied. Cannot insert the value NULL into column 'Client_ID', table 'C:INETPUBWWWROOTSWWEBSITEAPP_DATASOUTHWESTSOLUTIONS.MDF.dbo.client_premises_address'; column does not allow nulls. INSERT fails. The statement has been terminated.
However If I run Stored Procedure Test2 on its own it runs fine
Can anyone help with this issue? Is there something that I have done wrong in my stored procedures?
Also does anyone know If I can use the second stored procedure in a second webpage, but get the value that was created by running the stored proecdure in the previous webpage?

View 9 Replies View Related

This Stored Procedure Does Not Work! Why?

Apr 19, 2004

here is code i have


private void btnGetCustomers_Click(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection ();
conn.ConnectionString = " Data Source=(local); Initial Catalog=Northwind; Integrated Security=SSPI ";

SqlCommand cmd = conn.CreateCommand ();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "procCustomers";

// add the input parameters and set their values
cmd.Parameters.Add(new SqlParameter("@ContactName", SqlDbType.VarChar, 50));
cmd.Parameters["@ContactName"].Value = txbxContactName.Text;

conn.Open ();
SqlDataReader dr = cmd.ExecuteReader ();
if (dr.HasRows == true)
{
dgrdMyDataGrid.DataSource = dr;
dgrdMyDataGrid.DataBind ();
}
else
Response.Write("Nothing found.");

// clean up
dr.Close ();
conn.Close ();
}


and here is the stored procedure:

CREATE PROCEDURE procCustomers
@ContactName nvarchar(50)
AS
SELECT * FROM customers
WHERE customers.contactname LIKE @ContactName
ORDER BY customers.contactname ASC
GO

no compile errors, it just returns nothing even if there is supposed to be a match... what am doing wrong?

View 1 Replies View Related

Stored Procedure Cannot Work In .NET

Jul 30, 2005

Hi, i encounter a problem in the .NET. I have
write the stored prodeure for the registering function and it works
perfectly in the SQL Server. But when i called the stored procedure
from the .NET, it cannot work. Can someone pls help? Thanks!

Stored Procedure Codes:

CREATE PROCEDURE spAddProfile(@MemNRIC CHAR(9), @MemName
VARCHAR(30), @MemPwd VARCHAR(15), @MemDOB DATETIME, @MemEmail
VARCHAR(80), @MemContact VARCHAR(8))
AS

IF EXISTS(SELECT MemNRIC FROM DasMember WHERE MemEmail = @MemEmail)
    --RETURN -200

IF EXISTS(SELECT MemEmail FROM DasMember WHERE MemNRIC = @MemNRIC)
    RETURN -201

IF EXISTS(SELECT DATEDIFF(YEAR, @MemDOB, GETDATE())
    FROM DasMember
    WHERE DATEDIFF(YEAR, @MemDOB, GETDATE()) < 18)
    RETURN -202

INSERT INTO DasMember(MemNRIC, MemName, MemPwd, MemDOB, MemEmail,
MemContact, MemDateJoin) VALUES (@MemNRIC, @MemName, @MemPwd, @MemDOB,
@MemEmail, @MemContact, GETDATE())

IF @@ERROR <> 0
    RETURN @@ERROR

SET @MemNRIC = @@IDENTITY

RETURN

DECLARE @status int
EXEC @status = spAddProfile 'S1234567J', 'Kim', 'kim', '1986-01-01', 'kim@hotmail.com', '611616161'

SELECT 'Status' = @status

When called from .NET, it cannot works.. These are the codes:

Private Sub btnRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim connStr As String =
System.Configuration.ConfigurationSettings.AppSettings("SqlConnection.connectionString")

        Dim dbConn As New SqlConnection
        dbConn.ConnectionString = connStr
        Try
            dbConn.Open()
            Dim dbCmd As New SqlCommand
            dbCmd.Connection = dbConn
            dbCmd.CommandType = CommandType.StoredProcedure
            dbCmd.CommandText = "spAddProfile"

            Dim dbParam As SqlParameter
            dbParam = dbCmd.Parameters.Add("@return", SqlDbType.Int)
            dbParam.Direction = ParameterDirection.ReturnValue

            dbParam = dbCmd.Parameters.Add("@MemNRIC", SqlDbType.Char, 9)
            dbParam.Direction = ParameterDirection.Input
            dbParam.Value = txtNRIC.Text

           
dbParam = dbCmd.Parameters.Add("@MemName", SqlDbType.VarChar, 30)
            dbParam.Direction = ParameterDirection.Input
            dbParam.Value = txtName.Text

           
dbParam = dbCmd.Parameters.Add("@MemPwd", SqlDbType.VarChar, 15)
            dbParam.Direction = ParameterDirection.Input
            dbParam.Value = txtPwd.Text

            dbParam = dbCmd.Parameters.Add("@MemDOB", SqlDbType.DateTime)
            dbParam.Direction = ParameterDirection.Input
            dbParam.Value = txtDOB.Text

           
dbParam = dbCmd.Parameters.Add("@MemEmail", SqlDbType.VarChar, 80)
            dbParam.Direction = ParameterDirection.Input
            dbParam.Value = txtEmail.Text

           
dbParam = dbCmd.Parameters.Add("@MemContact", SqlDbType.VarChar, 8)
            dbParam.Direction = ParameterDirection.Input

            dbCmd.ExecuteNonQuery()

            Dim status As Integer
            status = dbCmd.Parameters("@return").Value
            If status = -201 Then
               
lblError.Text = "NRIC already exists!"

            ElseIf status = -202 Then
               
lblError.Text = "You must be at least 18 years to sign up!"

            Else
                lblError.Text = "Success"

            End If

        Catch ex As SqlException
            lblError.Text = ex.Message

        Catch ex As Exception
            lblError.Text = ex.message
        End Try

    End Sub
End Class
 
Can someone pls help? Thanks a lot!! I appreciated it very much!!

View 7 Replies View Related

Stored Procedure Do Not Work

Oct 26, 2000

Hi


When I tried to execute a procedure it give me message:

"Too many arguments were supplied for procedure sp2_ge_ag15_01"

I am doing:
exec sp2_ge_ag11_01 306,'NOVO VELHO',Null,
'1968-04-15','M',90,.17,'novo@com.br','teste'
It has 9 parameters

the begin of the my procedure is:

CREATE procedure dbo.sp2_ge_ag11_01(@Pcd_ficha integer,
@Pnm_ficha varchar(60),
@Pcd_pac integer = null,
@Pdt_nas datetime,
@Psx_pac varchar(01),
@Ppes_pac smallint,
@Palt_pac float,
@Pemail1 varchar(50),
@Pobs varchar(254))

AS
etc...

What Happen

thank you in advance

View 3 Replies View Related

Stored Procedure Won&#39;t Work After Migrated To Sql 7.0

Sep 28, 2000

Do anybody aware of any problems with the way that sql 7.0 converting stored procedures from sql 6.5...thanks

View 1 Replies View Related

Help! Stored Procedure Does Not Work On Second Server

Sep 8, 1999

I have a stored procedure that works on my development server but when I placed it on the server that is to be the prodcuction server i get the following response:

output ----------------
The name specified is not recognized as an internal or external command, operable program or batch file.
This is the procedure:

CREATE PROCEDURE sp_OutputClaim @OutFile varchar(255), @CurAns char(8) AS

declare @CmdLine varchar(255)

select FieldX into ##TempTable from Table where FieldY = @CurAns

select @CmdLine = "exec master..xp_cmdshell 'bcp tempdb.dbo.##TempTable out
c:est" + @OutFile + " /Uxx /Pxxx /Sxx /f c:estcp.fmt'"

exec (@CmdLine)
drop table tempdb..##TempTable

Thanks for any help !!!!

Rob

View 1 Replies View Related

Trying To Work With Timestamp Stored As Integer (11:17 Am -&&> 1117)

Nov 7, 2006

My company uses some integration software to synchronize tables in our OpenVMS server to our MS SQL 2005 server so statistics and tasks can be performed there instead potentially impacting our main data processing operations.

The problem I'm running into is that timestamps in the tables are stored as date_shipment (datetime) and time_shipment (integer) instead of as a combined datetime_shipment (datetime). Date_shipment contains the date of the transaction with 00:00:00.000 for the time part, while time_shipment has the time of the event stored as an integer, so 8:00 am -> 800, 4:50 pm -> 1650, 8:00 pm -> 2000, etc.

Unfortunately, I'm stuck with what the integration software gives me, so I need to find some way of turning the time integer column into a real time that I can then combine with the date.

Does anyone know of a way to do this? I haven't had any luck while experimenting with different T-SQL yet.

Thanks,

Jason B.

View 1 Replies View Related

Sp_sproc_columns Does Not Seem To Work On Managed Stored Procedures

Jul 10, 2007

Hi,



I have written a stored procedure using C#.NET. I deployed it to SQL Server, and everything works fine.



However, an Third-Party app needs to see what parameters it can use for this SP by executing sp_sproc_columns <SP name>



sp_sproc_columns

Seems to work on normal SP's written in T-SQL, but not on Managed SP's. On my SP, sp_sproc_columns does not seem to work. It does not return the parameters. On normal SP's, it does.



Anyone have an idea why this is?

View 1 Replies View Related

Restored SQL 2000 Backup, Stored Procedures Don't Work

May 6, 2006

Hello
I have restored a SQL 2000 backup of my database, ever since my web applications are unable to use any of the stored procedures.
I get the following error:
Could not find stored procedure 'xxx'.

If I use enterprise manager and go to the procedures tab the procedure appears there.

Any ideas what is up?

PS: The username has been changed, before the backup it was "user1" now its something else. For some reason it still shows that the procedure object is owned by "user1". Could this be the problem?

Thanks in advance.

View 1 Replies View Related

Stored Procedure Sort Parameter Doesnt Work

Jul 22, 2006

Hello, I am trying to make this.

CREATE PROCEDURE [dbo].[P_SEL_ALLPERSONAS]

@nmpersona int,

@sortorder varchar(20)



AS

BEGIN

select nmpersona, dsprimernombre, dssegundonombre,

dsprimerapellido, dssegundoapellido

from personas

order by @sortorder

END



But I got this error. Please help



Msg 1008, Level 16, State 1, Procedure P_SEL_ALLPERSONAS, Line 13

The SELECT item identified by the ORDER BY number 1 contains a variable as part of the expression identifying a column position. Variables are only allowed when ordering by an expression referencing a column name.

View 5 Replies View Related

Does The .. Expression In Stored Procedure Work In SSRS 2000 ?

Mar 13, 2007

Hi,

I am not understanding this part of the problem. I am currently reusing a stored procedure that has a ".." as part of the select statement.

I can't put the select statement up here due to privacy but I have found the error where the error states the following:-

Invalid Column Prefix: AM, invalid table name.

I noticed that part of the select statement was the following:-

AM..Field1

I tried executing this stored procedure in the query analyzer and it works fine, but when I tried executing it in SSRS, it gives me the error. After searching through the internet for possible causes, I found out that it was the ".." was giving the error. Anyone knows why ? I found out that it was supposed to bypass any users and permissions to the table.

Thakns !

Bernard

View 1 Replies View Related

Using Return X In A Stored Procedure Doesn't Work With Table Adapters

Mar 9, 2007

Hi,

I was trying to create a simple SP that return a single value as follows:CREATE PROCEDURE IsListingSaved@MemberID INT,@ListingID INTASIF EXISTS (SELECT [Member_ID] FROM [Member_Listing_Link] WHERE [Member_ID] = @MemberID AND [Listing_ID] = @ListingID)    Return 1ELSE    Return 0GOWhen I try it out in the Tableadapter's preview table, I get the correct result (1, where the entries exist). However, in the BLL, I tried to get the value as:Dim intResult as IntegerintResult = CType(Adapter.IsListingSaved(intMemberID, intListingID), Integer). However, this always returns 0 (when it should be returning 1). P.S. Curiously, breakpoints skipped the VS generated code for the adapter. What could be the problem? Thanks,Wild Thing 

View 3 Replies View Related

SQL Server Insert Update Stored Procedure - Does Not Work The Same Way From Code Behind

Mar 13, 2007

All:
 I have created a stored procedure on SQL server that does an Insert else Update to a table. The SP starts be doing "IF NOT EXISTS" check at the top to determine if it should be an insert or an update.
When i run the stored procedure directly on SQL server (Query Analyzer) it works fine. It updates when I pass in an existing ID#, and does an insert when I pass in a NULL to the ID#.
When i run the exact same logic from my aspx.vb code it keeps inserting the data everytime! I have debugged the code several times and all the parameters are getting passed in as they should be? Can anyone help, or have any ideas what could be happening?
Here is the basic shell of my SP:
CREATE PROCEDURE [dbo].[spHeader_InsertUpdate]
@FID  int = null OUTPUT,@FLD1 varchar(50),@FLD2 smalldatetime,@FLD3 smalldatetime,@FLD4 smalldatetime
AS
Declare @rtncode int
IF NOT EXISTS(select * from HeaderTable where FormID=@FID)
 Begin  begin transaction
   --Insert record   Insert into HeaderTable (FLD1, FLD2, FLD3, FLD4)    Values (@FLD1, @FLD2, @FLD3,@FLD4)   SET @FID = SCOPE_IDENTITY();      --Check for error   if @@error <> 0    begin     rollback transaction     select @rtncode = 0     return @rtncode    end   else    begin     commit transaction     select @rtncode = 1     return @rtncode    end      endELSE
 Begin  begin transaction
   --Update record   Update HeaderTable SET FLD2=@FLD2, FLD3=@FLD3, FLD4=@FLD4    where FormID=@FID;
   --Check for error   if @@error <> 0    begin     rollback transaction     select @rtncode = 0     return @rtncode    end   else    begin     commit transaction     select @rtncode = 2     return @rtncode   end
End---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
 Thanks,
Blue.

View 5 Replies View Related

Stored Proc - Output Parameter Does Not Work With Nested Level

Apr 26, 2004

Anyone can help with this question: thanks

in a asp .net application, I call a stored procedure which have a output parameter.
the output parameter works find in sql session, but not in the asp .net application.

if I put select msg_out = "error message" in position A(see below for stored proc), it works fine
if I put them inside the if statement, the output parameter wont work in asp .net application, but fine in SQL session
The stored proc was created like this:

Create procedure XXXXXXX
(@msg_out varchar(80) OUTPUT
)
as
begin

while exists (*******)
begin
//position A
if certain condition
begin

select msg_out = "error message"
return 1
end

end


end


end

It seems to me that anything inside if - the second begin...end - it wont get executed.

Anyone has got a clue

Any help much appreciated!

View 5 Replies View Related

SQL 2012 :: SSIS - Execute Stored Procedure With Parameters Does Not Work

Jun 9, 2015

Using the following:

SQL Server: SQL Server 2012
Visual Studio 2012

I have created an SSIS package where I have added an Execute SQL Task to run an existing stored procedure in my SQL database.

General:
Result Set: None
Connection Type: OLE DB
SourceType: Direct Input
IsQueryStoredProcedure: False (this is greyed out and cannot be changed)
Bypass Prepare: True

When I use the following execute statement where I am "Hard Coding" in the parameters, the stored procedure runs successfully and it places the data into the table per the stored procedure.

SQLStatement: dbo.sp_ml_location_load @system_cd='03', @location_type_cd=Store;

However, the @system_cd parameter can change, so I wanted to set these parameters up as variables and use the parameter mapping in the Execute SQL Task.

I have set this up as follows and it runs the package successfully but it does not put the data into the table. The only thing I can figure is either I have the variables set up incorrectly or the parameter mapping set up incorrectly.

Stored procedure variables:

ALTER PROCEDURE [dbo].[sp_ml_location_load]
(@system_cd nvarchar(10), @location_type_cd nvarchar(10))
AS
BEGIN .....................

Here is my set up, what is wrong here:

I Created these Variables:

Name Scope Data Type Value
system_cd Locations String '03'
location_type_cd Locations String Store

I added these parameter mappings in the Execute SQL Task

Variable Name Direction Data TypeParameter NameParameter Size
User::system_cd Input NVARCHAR@system_cd -1
User::location_type_cd Input NVARCHAR@location_type_cd -1

I used this SQLStatement: EXEC dbo.sp_ml_location_load ?,

It runs the package successfully but it does not put the data into the table.

View 2 Replies View Related

Temporary Table In Stored Procedure Doesn't Work From SQLDataSource

Feb 20, 2008

I have a stored procedure with the following:


CREATE TABLE #t1 (... ...);


WITH temp AS (....)

INSERT INTO #t1

SELECT .... FROM temp LEFT OUTER JOIN anothertable ON ...


This stored procedure works fine in Management Studio.

I then use this stored procedure in an ASP.NET page via a SQLDataSource object. The ASP.NET code compiles without error, but the result returned is empty (my bounded GridView object has zero rows). From Web Developer, if I try to Refresh Schema on the SQLDATASource object, I get an error: "Invalid object name '#t1'. The error is at the red #1 as I tried putting something else at that location to confirm it.

What does the error message mean and what have I done wrong?

Thanks.

View 5 Replies View Related

Learn To Access Stored Procedures With ADO.NET 2.0-VB 2005:How To Work With Output Parameters &&amp; Report Their Values In VB Forms?

Feb 11, 2008

Hi all,

In my SQL Server Management Studio Express (SSMSE), pubs Database has a Stored Procedure "byroyalty":

ALTER PROCEDURE byroyalty @percentage int

AS

select au_id from titleauthor

where titleauthor.royaltyper = @percentage

And Table "titleauthor" is:
au_id title_id au_ord royaltyper




172-32-1176
PS3333
1
100

213-46-8915
BU1032
2
40

213-46-8915
BU2075
1
100

238-95-7766
PC1035
1
100

267-41-2394
BU1111
2
40

267-41-2394
TC7777
2
30

274-80-9391
BU7832
1
100

409-56-7008
BU1032
1
60

427-17-2319
PC8888
1
50

472-27-2349
TC7777
3
30

486-29-1786
PC9999
1
100

486-29-1786
PS7777
1
100

648-92-1872
TC4203
1
100

672-71-3249
TC7777
1
40

712-45-1867
MC2222
1
100

722-51-5454
MC3021
1
75

724-80-9391
BU1111
1
60

724-80-9391
PS1372
2
25

756-30-7391
PS1372
1
75

807-91-6654
TC3218
1
100

846-92-7186
PC8888
2
50

899-46-2035
MC3021
2
25

899-46-2035
PS2091
2
50

998-72-3567
PS2091
1
50

998-72-3567
PS2106
1
100

NULL
NULL
NULL
NULL
////////////////////////////////////////////////////////////////////////////////////////////
I try to do an ADO.NET 2.0-VB 2005 programming in my VB 2005 Express to get @percentage printed out in the VB Form1. I read some articles in the websites and MSDN about this task and I am very confused about "How to Work with Output Parameters & Report their Values in VB Forms": (1) Do I need the Form.vb [Design] and specify its properties of the object and classes I want to printout? (2) After the SqlConnectionString and the connection.Open(), how can I bring the value of @percentage to the Form.vb? (3) The following is my imcomplete, crude draft code:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes

Public Class Form1

Dim connectionString As String = "Data Source=.SQLEXPRESS;Initial Catalog=pubs;Integrated Security=SSPI;"

Dim connection As SqlConnection = New

SqlConnection(connectionString)

Try

connection.Open()

Dim command As SqlCommand = New SqlCommand("byroyalty", connection)

command.CommandType = CommandType.StoredProcedure
...................................................................
..................................................................
etc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
From the above-mentioned (1), (2) and (3), you can see how much I am lost/confused in attempting to do this task. Please help and give me some guidances and good key instructions for getting the output parameter printed out in the FORM.vb in my VB 2005 Express project.

Thanks in advance,
Scott Chang


View 11 Replies View Related

The Multi Delete &&amp; Multi Update - Stored Procedure Not Work Ok

Feb 4, 2008

the stored procedure don't delete all the records
need help



Code Snippet
DECLARE @empid varchar(500)
set @empid ='55329429,58830803,309128726,55696314'
DELETE FROM [Table_1]
WHERE charindex(','+CONVERT(varchar,[empid])+',',','+@empid+',') > 0
UPDATE [empList]
SET StartDate = CONVERT(DATETIME, '1900-01-01 00:00:00', 102), val_ok = 0
WHERE charindex(','+CONVERT(varchar,[empid])+',',','+@empid+',') > 0
UPDATE [empList]
SET StartDate = CONVERT(DATETIME, '1900-01-01 00:00:00', 102), val_ok = 0
WHERE charindex(','+CONVERT(varchar,[empid])+',',','+@empid+',') > 0




TNX

View 2 Replies View Related

Why Does This Not Work

Feb 27, 2007

 My error is that 'Name tr is not declared'  tr.Rollback() I tried moving the 'Dim tr As SqlTransaction' outside the try but then I get 'Variable tr is used before it si assinged a value'.
What is the correct way?        Try            conn.Open()            Dim tr As SqlTransaction            tr = conn.BeginTransaction()            cmdInsert1.Transaction = tr            cmdInsert1.ExecuteNonQuery()            cmdInsert2.Transaction = tr            cmdInsert2.ExecuteNonQuery()            cmdInsert3.Transaction = tr            cmdInsert3.ExecuteNonQuery()            tr.Commit()        Catch objException As SqlException           tr.Rollback()            Dim objError As SqlError            For Each objError In objException.Errors                Response.Write(objError.Message)            Next        Finally            conn.Close()        End Try 

View 5 Replies View Related

Can't Get LIKE To Work

Apr 19, 2007

I have the below procedure that will not work- I must be losing my mind, this is not that difficult - mental roadblock for me.
Using SQL Server 2000 to create SP being called by ASP.Net with C# code behind
stored procedure only returns if input exactly matches L_Name
PROCEDURE newdawn.LinkNameLIKESearch @L_Name nvarchar(100)AS SELECT [L_Name], [L_ID], [C_ID], [L_Enabled], [L_Rank], [L_URL] FROM tblContractorLinkInfo WHERE L_Name LIKE @L_Name RETURN
I tried: WHERE L_Name LIKE ' % L_Name % '  no luck. What am I missing?
Thank you
 

View 2 Replies View Related

SP Does Not Work.

May 24, 2007

SP below is not work.It gives null for @kaysay 
I used parametric table name. Is this the problem? 
My aim to calculate record count of a table
Thanks. 
 
CREATE PROCEDURE Tablodaki_Kayit_Sayisi(@TABLO varchar(30))AS
Declare @kaysay bigintDeclare @SQLString nvarchar(100)Declare @Param nvarchar(100)
Set @SQLString = N'Select @kaysayOUT = count(BELGE) From ' + @TABLOSet @Param = N'@kaysayOUT bigint'
Execute sp_executesql@SQLString,@Param,@kaysayOUT = @kaysay
Select @kaysay
Return
 
GO

View 3 Replies View Related

Can Anyone Tell Me Why The Following Sql Does Not Work?

Sep 3, 2007

SELECT H.id, H.CategoryID ,H.Image ,H.StoryId ,H.Publish, H.PublishDate, H.Date ,H.Deleted ,SL.ListTitle,C.CategoryTitle
FROM HomePageImage H
JOIN shortlist SL on H.StoryId = SL.id
(INNER JOIN category C on H.CategoryId = C.CategoryId)
order by date DESC

View 4 Replies View Related

Please Help Me To Keep My Work...(:

Apr 12, 2004

Hello,

I am trying to query with my stored procedure. I am getting comma separated list as input parameter (which is VARCHAR) .

The table column, which I have to compare with input parameter value , is in INTEGER datatype.

So when , I compare Like as follows:-

" AND TABLE1.EMPID IN (@INPUTPARAMETERLIST)"

I am getting error. "Syntax error converting the varchar value '34,343' to a column of data type int."

Could anybody help me , to solve this ?

Thanks !

Nicol

View 1 Replies View Related

Why Won't This Work!?

Aug 31, 2004

I have a textbox and a checkbox on a form and I'd like to add both values to a db. The textbox value gets inserted fine but I'm having trouble with the checkbox. Any ideas would be greatly appreciated.

Thanks

Form1 is the column in my db.




SqlCommand myCmd = new SqlCommand();

myCmd.Parameters.Add("@ClientCode",SqlDbType.VarChar).Value = TextBox2.Text;

myCmd.CommandText = "UPDATE table SET Form1 = 'Yes' WHERE ClientCode = @ClientCode";


sqlConnection1.Open();
myCmd.Connection = sqlConnection1;

if( CheckBox1.Checked == true)
{
myCmd.ExecuteNonQuery();
}

sqlConnection1.Close();

View 3 Replies View Related

DBA Work

Aug 29, 2001

Hi,

Beside working right from the server how else someone can perform the SQL admistration job, I guess my question is how do most SQL DBA perform their administration without going to the server directly. Anyone --- can help please??

Thanks in advance.

View 2 Replies View Related

Does This Work?

Mar 15, 2007

Declare @StartDate datetime
Declare @EndDate Datetime
Set @StartDate = dateadd(day, datediff(day, 0, getdate()), 0)
Set @EndDate = getdate()

The job runs at 11:30 pm so I want the start date to be the same but the time to be equal to 00:00:00.0 When I run the getdate does it also return a time stamp?

The Yak Village Idiot

View 1 Replies View Related

Why Did It Work?

Aug 6, 2007

I had a problem where some users were experiencing timeouts when trying to add a single record to a table with 2.3 million records.
It's not a very wide table; only 10 columns and the biggest column in varchar 500. The rest are guid, datetime, tinyint...

There is also an old VB app that inserts about 3000 records a day into this table during office hours while users occasionally try and insert a record into this table.

Something said to me that the problem could be indexes but I wasn't quite sure because I though indexes only have an impact on select, delete & update. And not particulary on insert. But I checked it out anyway and noticed that the 3 indexes (1 column PK, 1 column Clustered & 1 column non-clustered) weren't padded. So I changed that (Fill Factor 95) and the problem has gone away. But why? I thought the insert would just have appended it to the end of the index before I made this change? Why would that time out?

View 3 Replies View Related

Why Does One Work, But Not The Other?

Mar 25, 2008



I have the following queries. The first returns the 'Unknown' row, the second works the way I would expect. Are my expectations wrong? Can someone describe for me what is going on?

Thanks




Code Snippet
select *
FROM
SynonymComFinancialCategory b
LEFT JOIN TT_FinancialCategory a
ON
a.FinanceGroup = b.FinanceGroup
AND a.FinanceCode = b.FinanceCode
AND a.Finance = b.Finance
AND b.Finance <> 'Unknown'
WHERE
a.FinanceGroup IS NULL
AND a.FinanceCode IS NULL
AND a.Finance IS NULL










Code Snippet
select *
FROM
SynonymComFinancialCategory b
LEFT JOIN TT_FinancialCategory a
ON
a.FinanceGroup = b.FinanceGroup
AND a.FinanceCode = b.FinanceCode
AND a.Finance = b.Finance
WHERE
a.FinanceGroup IS NULL
AND a.FinanceCode IS NULL
AND a.Finance IS NULL
AND b.Finance <> 'Unknown'

View 8 Replies View Related

Coalesce Does Not Seem To Work

Sep 27, 2006

  Hi,I have the following table with some sample values, I want to return the first non null value in that order. COALESCE does not seem to work for me, it does not return the 3rd record. I need to include this in my select statement. Any urgent help please.Mobile    Business     PrivateNULL        345           NULL4646        65464        65765NULL                        564654654     564           6546I want the following as my results:Number3454646564654654Select COALESCE(Mobile,Business,Private) as Number  from Table returns:3454646654654 (this is a test to see if private returns & it did with is not null but then how do i include in my select statement to show any one of the 3 fields)select mobile,business,private where private is not null returns:657655646546thanks

View 1 Replies View Related







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