473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Displaying Stored Procedures using Grid View

Hi,

using .net 2
sql server 2005

Here is my situation:

I'm passing a variable in the url from a selection on Page A and need
to display the results on the Results page be based on that variable
in the url. I would like that variable to trigger a stored and
display information in formView or Grid View. Whats the best way to
accomplish this?

Page A

This is passing var from grid view:
<asp:HyperLinkField DataTextField="Open Issues"
DataNavigateUrlFields="Ticket Number"
DataNavigateUrlFormatString="results2.aspx?{0}" Target="_blank"
HeaderText="Open Issues" />

Results Page

<asp:FormView ID="FormView1" runat="server" DataKeyNames="Ticket
Number"
DataSourceID="SqlDataSource1"
OnPageIndexChanging="FormView1_PageIndexChanging">
<EditItemTemplate>
Ticket Number:
<asp:Label ID="Ticket_NumberLabel1" runat="server"
Text='<%# Eval("[Ticket Number]") %>'>
</asp:Label><br />
Technician Assigned:
<asp:TextBox ID="Technician_AssignedTextBox"
runat="server" Text='<%# Bind("[Technician Assigned]") %>'>
</asp:TextBox><br />
Issue Description:
<asp:TextBox ID="Issue_DescriptionTextBox"
runat="server" Text='<%# Bind("[Issue Description]") %>'>
</asp:TextBox><br />
Open Date:
<asp:TextBox ID="Open_DateTextBox" runat="server"
Text='<%# Bind("[Open Date]") %>'>
</asp:TextBox><br />
Work Notes:
<asp:TextBox ID="Work_NotesTextBox" runat="server"
Text='<%# Bind("[Work Notes]") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
Ticket Number:
<asp:TextBox ID="Ticket_NumberTextBox"
runat="server" Text='<%# Bind("[Ticket Number]") %>'>
</asp:TextBox><br />
Technician Assigned:
<asp:TextBox ID="Technician_AssignedTextBox"
runat="server" Text='<%# Bind("[Technician Assigned]") %>'>
</asp:TextBox><br />
Issue Description:
<asp:TextBox ID="Issue_DescriptionTextBox"
runat="server" Text='<%# Bind("[Issue Description]") %>'>
</asp:TextBox><br />
Open Date:
<asp:TextBox ID="Open_DateTextBox" runat="server"
Text='<%# Bind("[Open Date]") %>'>
</asp:TextBox><br />
Work Notes:
<asp:TextBox ID="Work_NotesTextBox" runat="server"
Text='<%# Bind("[Work Notes]") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
Ticket Number:
<asp:Label ID="Ticket_NumberLabel" runat="server"
Text='<%# Eval("[Ticket Number]") %>'>
</asp:Label><br />
Technician Assigned:
<asp:Label ID="Technician_AssignedLabel"
runat="server" Text='<%# Bind("[Technician Assigned]") %>'>
</asp:Label><br />
Issue Description:
<asp:Label ID="Issue_DescriptionLabel"
runat="server" Text='<%# Bind("[Issue Description]") %>'>
</asp:Label><br />
Open Date:
<asp:Label ID="Open_DateLabel" runat="server"
Text='<%# Bind("[Open Date]") %>'>
</asp:Label><br />
Work Notes:
<asp:Label ID="Work_NotesLabel" runat="server"
Text='<%# Bind("[Work Notes]") %>'>
</asp:Label><br />
</ItemTemplate>
</asp:FormView>

May 6 '07 #1
12 4680
On May 6, 6:29 pm, brwalias <brwal...@gmail.comwrote:
Hi,

using .net 2
sql server 2005

Here is my situation:

I'm passing a variable in the url from a selection on Page A and need
to display the results on the Results page be based on that variable
in the url. I would like that variable to trigger a stored and
display information in formView or Grid View. Whats the best way to
accomplish this?

Page A

This is passing var from grid view:
<asp:HyperLinkField DataTextField="Open Issues"
DataNavigateUrlFields="Ticket Number"
DataNavigateUrlFormatString="results2.aspx?{0}" Target="_blank"
HeaderText="Open Issues" />

Results Page

<asp:FormView ID="FormView1" runat="server" DataKeyNames="Ticket
Number"
DataSourceID="SqlDataSource1"
OnPageIndexChanging="FormView1_PageIndexChanging">
<EditItemTemplate>
Ticket Number:
<asp:Label ID="Ticket_NumberLabel1" runat="server"
Text='<%# Eval("[Ticket Number]") %>'>
</asp:Label><br />
Technician Assigned:
<asp:TextBox ID="Technician_AssignedTextBox"
runat="server" Text='<%# Bind("[Technician Assigned]") %>'>
</asp:TextBox><br />
Issue Description:
<asp:TextBox ID="Issue_DescriptionTextBox"
runat="server" Text='<%# Bind("[Issue Description]") %>'>
</asp:TextBox><br />
Open Date:
<asp:TextBox ID="Open_DateTextBox" runat="server"
Text='<%# Bind("[Open Date]") %>'>
</asp:TextBox><br />
Work Notes:
<asp:TextBox ID="Work_NotesTextBox" runat="server"
Text='<%# Bind("[Work Notes]") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
Ticket Number:
<asp:TextBox ID="Ticket_NumberTextBox"
runat="server" Text='<%# Bind("[Ticket Number]") %>'>
</asp:TextBox><br />
Technician Assigned:
<asp:TextBox ID="Technician_AssignedTextBox"
runat="server" Text='<%# Bind("[Technician Assigned]") %>'>
</asp:TextBox><br />
Issue Description:
<asp:TextBox ID="Issue_DescriptionTextBox"
runat="server" Text='<%# Bind("[Issue Description]") %>'>
</asp:TextBox><br />
Open Date:
<asp:TextBox ID="Open_DateTextBox" runat="server"
Text='<%# Bind("[Open Date]") %>'>
</asp:TextBox><br />
Work Notes:
<asp:TextBox ID="Work_NotesTextBox" runat="server"
Text='<%# Bind("[Work Notes]") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
Ticket Number:
<asp:Label ID="Ticket_NumberLabel" runat="server"
Text='<%# Eval("[Ticket Number]") %>'>
</asp:Label><br />
Technician Assigned:
<asp:Label ID="Technician_AssignedLabel"
runat="server" Text='<%# Bind("[Technician Assigned]") %>'>
</asp:Label><br />
Issue Description:
<asp:Label ID="Issue_DescriptionLabel"
runat="server" Text='<%# Bind("[Issue Description]") %>'>
</asp:Label><br />
Open Date:
<asp:Label ID="Open_DateLabel" runat="server"
Text='<%# Bind("[Open Date]") %>'>
</asp:Label><br />
Work Notes:
<asp:Label ID="Work_NotesLabel" runat="server"
Text='<%# Bind("[Work Notes]") %>'>
</asp:Label><br />
</ItemTemplate>
</asp:FormView>
The SqlDataSource Control has a SelectParameter section where you can
specify parameters for your query. There is the QueryStringParameter
section used to bind the values of the query string to a parameter
used in a parameterized query.

So, your code would be as the follows

<asp:SqlDataSource ID="SqlDataSource1"
SelectCommand="SELECT .... WHERE state=@state"
....>
<SelectParameters>
<asp:QueryStringParameter Name="state" QueryStringField="state" />
</SelectParameters>
</asp:SqlDataSource>

Where:

Name is the name of @parameter
QueryStringField is the key section of the QueryString

Note, usage of the QueryStringParameter does not perform any
validation of input from the client and the real best way to
accomplish this is the code-behind model.

The QueryStringParameter does not validate the value passed by the
query string in any way; it uses the raw value. In

May 6 '07 #2
On May 6, 8:53 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
>
The QueryStringParameter does not validate the value passed by the
query string in any way; it uses the raw value. In- Hide quoted text -
Too quick on send button: The QueryStringParameter does not validate
the value passed by the query string in any way; it uses the raw
value. In most cases you can validate the value of the
QueryStringParameter before it is used by a data source control by
handling an event, such as the Selecting, Updating, Inserting, or
Deleting event exposed by the data source control you are using. If
the value of the parameter does not pass your validation tests, you
can cancel the data operation by setting the Cancel property of the
associated CancelEventArgs class to true.

http://msdn2.microsoft.com/en-us/lib...er(VS.80).aspx
May 6 '07 #3
Page A:

This is a hyper link which represents ticketid generated from sql that
the user will click on to view row. once clicked, a new window needs
to open with additional details from that row stored in a stored
procedure.

<asp:HyperLinkField DataTextField="Open Issues"
DataNavigateUrlFields="Ticket Number"
DataNavigateUrlFormatString="results2.aspx?ticketi d={0}"
Target="_blank" HeaderText="Open Issues" />

--------------------------

var seems to pass as i have it printing on the results page just to
confirm. I have also added the details view as follows:

<asp:DataList ID="DataList1" runat="server" DataKeyField="Ticket
Number" DataSourceID="SqlDataSource1">

<ItemTemplate>
Ticket Number:
<asp:Label ID="Ticket_NumberLabel" runat="server"
Text='<%# Eval("[Ticket Number]") %>'>
</asp:Label><br />
Technician Assigned:
<asp:Label ID="Technician_AssignedLabel"
runat="server" Text='<%# Eval("[Technician Assigned]") %>'>
</asp:Label><br />
Issue Description:
<asp:Label ID="Issue_DescriptionLabel"
runat="server" Text='<%# Eval("[Issue Description]") %>'>
</asp:Label><br />
Open Date:
<asp:Label ID="Open_DateLabel" runat="server"
Text='<%# Eval("[Open Date]") %>'>
</asp:Label><br />
Work Notes:
<asp:Label ID="Work_NotesLabel" runat="server"
Text='<%# Eval("[Work Notes]") %>'>
</asp:Label><br />
<br />
</ItemTemplate>
</asp:DataList><asp:SqlDataSource ID="SqlDataSource1"
runat="server" ConnectionString="<%$
ConnectionStrings:webhelp2ConnectionString %>"
SelectCommand="sp_dticket"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter Name="ticketid"
QueryStringField="ticketid" />
</SelectParameters>
</asp:SqlDataSource>

--------------------------------------------

Stored procedure i'm using:

Declare @ticketid as varchar (20)
Declare @Technician as varchar (20)
set @Technician=(SELECT email

FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))

SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'

FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))
the query works as it should in sql but once i bring it into vs web
developer the browser gives me errors. It just need the details view
on the results page to pull the sp from sql based off the var being
passed in the url.

Thanks again,

Bryan

May 7 '07 #4
On May 6, 11:57 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On May 6, 8:53 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
The QueryStringParameter does not validate the value passed by the
query string in any way; it uses the raw value. In- Hide quoted text -

Too quick on send button: The QueryStringParameter does not validate
the value passed by the query string in any way; it uses the raw
value. In most cases you can validate the value of the
QueryStringParameter before it is used by a data source control by
handling an event, such as the Selecting, Updating, Inserting, or
Deleting event exposed by the data source control you are using. If
the value of the parameter does not pass your validation tests, you
can cancel the data operation by setting the Cancel property of the
associated CancelEventArgs class to true.

http://msdn2.microsoft.com/en-us/lib...webcontrols.qu...


Page A:

This is a hyper link which represents ticketid generated from sql that
the user will click on to view row. once clicked, a new window needs
to open with additional details from that row stored in a stored
procedure.

<asp:HyperLinkField DataTextField="Open Issues"
DataNavigateUrlFields="Ticket Number"
DataNavigateUrlFormatString="results2.aspx?ticketi d={0}"
Target="_blank" HeaderText="Open Issues" />

--------------------------

var seems to pass as i have it printing on the results page just to
confirm. I have also added the details view as follows:

<asp:DataList ID="DataList1" runat="server" DataKeyField="Ticket
Number" DataSourceID="SqlDataSource1">

<ItemTemplate>
Ticket Number:
<asp:Label ID="Ticket_NumberLabel" runat="server"
Text='<%# Eval("[Ticket Number]") %>'>
</asp:Label><br />
Technician Assigned:
<asp:Label ID="Technician_AssignedLabel"
runat="server" Text='<%# Eval("[Technician Assigned]") %>'>
</asp:Label><br />
Issue Description:
<asp:Label ID="Issue_DescriptionLabel"
runat="server" Text='<%# Eval("[Issue Description]") %>'>
</asp:Label><br />
Open Date:
<asp:Label ID="Open_DateLabel" runat="server"
Text='<%# Eval("[Open Date]") %>'>
</asp:Label><br />
Work Notes:
<asp:Label ID="Work_NotesLabel" runat="server"
Text='<%# Eval("[Work Notes]") %>'>
</asp:Label><br />
<br />
</ItemTemplate>
</asp:DataList><asp:SqlDataSource ID="SqlDataSource1"
runat="server" ConnectionString="<%$
ConnectionStrings:webhelp2ConnectionString %>"
SelectCommand="sp_dticket"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter Name="ticketid"
QueryStringField="ticketid" />
</SelectParameters>
</asp:SqlDataSource>

--------------------------------------------

Stored procedure i'm using:

Declare @ticketid as varchar (20)
Declare @Technician as varchar (20)
set @Technician=(SELECT email

FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))

SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'

FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))
the query works as it should in sql but once i bring it into vs web
developer the browser gives me errors. It just need the details view
on the results page to pull the sp from sql based off the var being
passed in the url.

Thanks again

May 7 '07 #5
On May 7, 11:27 pm, brwalias <brwal...@gmail.comwrote:
>
the query works as it should in sql but once i bring it into vs web
developer the browser gives me errors. It just need the details view
on the results page to pull the sp from sql based off the var being
passed in the url.
The code you have posted here a T-SQL, do you mean that it is created
as a stored procedure in the database?

CREATE PROCEDURE ...

What is the "sp_dticket"?

May 7 '07 #6
On May 7, 2:48 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On May 7, 11:27 pm,brwalias<brwal...@gmail.comwrote:
the query works as it should in sql but once i bring it into vs web
developer the browser gives me errors. It just need the details view
on the results page to pull the sp from sql based off the var being
passed in the url.

The code you have posted here a T-SQL, do you mean that it is created
as a stored procedure in the database?

CREATE PROCEDURE ...

What is the "sp_dticket"?
Yes you are correct, we created sp_dticket as a stored procedure in
the database.

May 7 '07 #7
On May 7, 3:00 pm, brwalias <brwal...@gmail.comwrote:
On May 7, 2:48 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On May 7, 11:27 pm,brwalias<brwal...@gmail.comwrote:
the query works as it should in sql but once i bring it into vs web
developer the browser gives me errors. It just need the details view
on the results page to pull the sp from sql based off the var being
passed in the url.
The code you have posted here a T-SQL, do you mean that it is created
as a stored procedure in the database?
CREATE PROCEDURE ...
What is the "sp_dticket"?

Yes you are correct, we created sp_dticket as a stored procedure in
the database.
here is the stored procedure:

Stored procedure i'm using:

Declare @ticketid as varchar (20)
Declare @Technician as varchar (20)

set @Technician=(SELECT email

FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))

SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'

FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))

May 7 '07 #8
On May 8, 12:00 am, brwalias <brwal...@gmail.comwrote:
>
Yes you are correct, we created sp_dticket as a stored procedure in
the database.
Well, but the following code does then?

Declare @ticketid as varchar (20)
Declare @Technician as varchar (20)

when you have the following code:

<asp:QueryStringParameter Name="ticketid"
QueryStringField="ticketid" />

you mean that the ticketid has to be the input parameter of the stored
procedure. And here as I see you do "Declare @ticketid", it means you
create a new parameter inside(?) the stored procedure

Please post the complete code of the sp_dticket here (starting CREATE
PROCEDURE...)
I want to look on it.

Thanks!

May 7 '07 #9
On May 8, 12:10 am, brwalias <brwal...@gmail.comwrote:
>
here is the stored procedure:

Stored procedure i'm using:

Declare @ticketid as varchar (20)
Declare @Technician as varchar (20)

set @Technician=(SELECT email

FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))

SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'

FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))- Hide quoted text -
Bryan, sorry it is not the stored procedure :-)

The real stored procedure should look like

---------------------------------------------
CREATE PROCEDURE dbo.sp_dticket
(
@ticketid as varchar(20)
)
AS

Declare @Technician as varchar (20)

set @Technician=(SELECT email

FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))

SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'
FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))

GO
---------------------------------------------

You should execute this code to create the procedure.

Once created you can test it as

EXEC sp_dticket 'yourtestticketid'

May 7 '07 #10
On May 7, 3:23 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On May 8, 12:10 am,brwalias<brwal...@gmail.comwrote:


here is the stored procedure:
Stored procedure i'm using:
Declare @ticketid as varchar (20)
Declare @Technician as varchar (20)
set @Technician=(SELECT email
FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))
SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'
FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))- Hide quoted text -

Bryan, sorry it is not the stored procedure :-)

The real stored procedure should look like

---------------------------------------------
CREATE PROCEDURE dbo.sp_dticket
(
@ticketid as varchar(20)
)
AS

Declare @Technician as varchar (20)

set @Technician=(SELECT email

FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))

SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'
FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))

GO
---------------------------------------------

You should execute this code to create the procedure.

Once created you can test it as

EXEC sp_dticket 'yourtestticketid'
Alexey,

That didn't appear to work. When i passed the variable in the url
nothing was displayed on the results page; not even an error. maybe
i'm not capturing the var correctly? Its easy to get the details view
to display a simple select query but this query seems to be giving me
more problems than expected. This third party schema we're working
with is far from forgiving.

May 7 '07 #11
On May 7, 3:23 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On May 8, 12:10 am,brwalias<brwal...@gmail.comwrote:


here is the stored procedure:
Stored procedure i'm using:
Declare @ticketid as varchar (20)
Declare @Technician as varchar (20)
set @Technician=(SELECT email
FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))
SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'
FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))- Hide quoted text -

Bryan, sorry it is not the stored procedure :-)

The real stored procedure should look like

---------------------------------------------
CREATE PROCEDURE dbo.sp_dticket
(
@ticketid as varchar(20)
)
AS

Declare @Technician as varchar (20)

set @Technician=(SELECT email

FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))

SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'
FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))

GO
---------------------------------------------

You should execute this code to create the procedure.

Once created you can test it as

EXEC sp_dticket 'yourtestticketid'
Alexey,

Please disregard my last post, it's working correctly! Thank you very
much for your time and patience working with me. Your help was
greatly appreciated.

Take care,

Bryan

May 7 '07 #12
On May 8, 12:57 am, brwalias <brwal...@gmail.comwrote:
On May 7, 3:23 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:


On May 8, 12:10 am,brwalias<brwal...@gmail.comwrote:
here is the stored procedure:
Stored procedure i'm using:
Declare @ticketid as varchar (20)
Declare @Technician as varchar (20)
set @Technician=(SELECT email
FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))
SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'
FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))- Hide quoted text -
Bryan, sorry it is not the stored procedure :-)
The real stored procedure should look like
---------------------------------------------
CREATE PROCEDURE dbo.sp_dticket
(
@ticketid as varchar(20)
)
AS
Declare @Technician as varchar (20)
set @Technician=(SELECT email
FROM dbo.tech INNER JOIN dbo.job_ticket ON tech.client_id =
job_ticket.assigned_tech_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20)))
SELECT job_ticket.job_ticket_id 'Ticket Number', @Technician
'Technician Assigned',job_ticket.subject 'Issue Description',
report_date 'Open Date',tech_note.note_text 'Work Notes'
FROM job_ticket INNER JOIN dbo.tech_note ON tech_note.job_ticket_Id =
job_ticket.job_ticket_id WHERE job_ticket.job_ticket_id =Cast
(@ticketid as varchar (20))
GO
---------------------------------------------
You should execute this code to create the procedure.
Once created you can test it as
EXEC sp_dticket 'yourtestticketid'

Alexey,

Please disregard my last post, it's working correctly! Thank you very
much for your time and patience working with me. Your help was
greatly appreciated.

Take care,

Bryan- Hide quoted text -

- Show quoted text -
You are very welcome

May 8 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jarrod Morrison | last post by:
Hi all Im relatively new to using stored procedures and im not sure if it is possible to do what I am trying to do so any help here is greatly appreciated. I am using the variable @MachineName...
1
by: rdshultz | last post by:
Good morning everyone. Could someone tell me if there is a book out there which gives examples of both VB.net code and creating SQL Server 2000 stored procedures and how you get them to work...
0
by: billmiami2 | last post by:
Perhaps many of you MS Access fanatics already know this, but it seems that stored procedures and views are possible in Jet. I thought I would leave this message just in case it would help anyone....
5
by: Tim Marshall | last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with interest and on reading the post describing Lauren Quantrell's SmartTree, I've run into something I don't understand: Stored...
1
by: mimo | last post by:
Hi, I'm trying to use Stored Procedures with a Grid View and everytime I try the update and the delete stored procedures fail. By the way I am doing this through the wizard. Is there a...
28
by: mooreit | last post by:
The purpose for my questions is accessing these technologies from applications. I develop both applications and databases. Working with Microsoft C#.NET and Microsoft SQL Server 2000 Production and...
12
by: Jason Huang | last post by:
Hi, In my C# Windows Form application project, I have done all queries on my codes. Now I wanna try using the Stored Procedure. But I am not clear about why using the stored procedure. Would...
1
by: mandible | last post by:
Hello I was wondering if I"m doing something wrong with using db2advis I have 2 stored procedures are are massive, I created an input file to call both of these stored procedures and I dont' seem...
0
by: vanesa | last post by:
Hi, In a client we must begin to program many stored procedures of DB2. The following doubts arise to me that I raise you to see if you can help me: 1. From a point of view of the programming:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.