473,503 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The multi-part identifier "ticket.ticketid" could not be bound.

8 New Member
hi everyone ..
I am a student and i am learning how to create form using vb but i am stuck here since this is my school project, I need someone to help me to figgure out what is wrong with my code.also i try to create store procedure in sql 2005 and it give me This error Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the varchar value '@Itinerary.ticketid' to data type int(but my ticketid value already integer not varchar). Please help me ! And Thank you for taking time to read my massage.

this is in form VB
Expand|Select|Wrap|Line Numbers
  1. Private Sub orderidtxbx_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles orderidtxbx.Click
  2.         sqlconnection = New SqlConnection("Data Source= xxxx;Initial Catalog = xxxx; user ID = sa; Password = xxxxx;")
  3.         sqlcommand = New SqlCommand("select  Customer.LastName, Customer.FirstName from customer where ticket.ticketid ='" & orderidtxbx.Text & "'", sqlconnection)
  4.  
  5.         sqlconnection.Open()
  6.         sqldatareader = sqlcommand.ExecuteReader()
  7.         ListBox1.Items.Add(sqldatareader.Item("LastName") & " " & sqldatareader.Item("FirstName")


query in sql 2005,I need to make store procedure.


Expand|Select|Wrap|Line Numbers
  1. SELECT     Itinerary.FlightID, Itinerary.Class, Itinerary.Quantity, Ticket.Date, Flight.FlightNo, Flight.AirLine, Flight.DepartureDate, Flight.ArrivalDate, 
  2.                       Flight.DepartureTime, Flight.ArrivalTime, Flight.Price, Departure.DepartureLocation, Arrival.ArrivalLocation,GST=convert(int,Itinerary.Quantity*0.06*Flight.Price),PST=convert(int,Itinerary.Quantity*0.07*Flight.Price),TotalPrice=convert(int,(Itinerary.Quantity*0.06*Flight.Price)+(Itinerary.Quantity*0.07*Flight.Price)+Flight.Price)
  3. FROM         Flight INNER JOIN
  4.                       Itinerary ON Flight.FlightID = Itinerary.FlightID INNER JOIN
  5.                       Ticket ON Itinerary.TicketID = Ticket.TicketID INNER JOIN
  6.                       Departure ON Flight.DepartureLocationID = Departure.DepartureID INNER JOIN
  7.                       Arrival ON Flight.ArrivalLocationID = Arrival.ArrivalID
  8. WHERE     (Itinerary.ticketid = '@Itinerary.ticketid')

if i change WHERE (Itinerary.ticketid = 1)
it will read the data in the table.

I need to refer that itinerary.ticketid into textbox in form that's why i make like this WHERE (Itinerary.ticketid = '@Itinerary.ticketid') but i don't know what is worng with this.

This error Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the varchar value '@Itinerary.ticketid' to data type int(but my ticketid value already integer not varchar).
Nov 25 '07 #1
14 12030
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
hi,
Please remove the single quotes at the end of your sql Statement for the parameter.
Putting single quotes defines that as a string value (and not as a parameter anymore), so your parameter will be ignored
And hence the error

the end of the SQL should look like this

Expand|Select|Wrap|Line Numbers
  1. Arrival ON Flight.ArrivalLocationID = Arrival.ArrivalID
  2. WHERE     (Itinerary.ticketid = @Itinerary.ticketid)
Nov 25 '07 #2
dieselxeon
8 New Member
Thank you for replying.
I remove the quotes but it give me other error

Expand|Select|Wrap|Line Numbers
  1. SELECT     Itinerary.FlightID, Itinerary.Class, Itinerary.Quantity, Ticket.Date, Flight.FlightNo, Flight.AirLine, Flight.DepartureDate, Flight.ArrivalDate, 
  2.                       Flight.DepartureTime, Flight.ArrivalTime, Flight.Price, Departure.DepartureLocation, Arrival.ArrivalLocation,GST=convert(int,Itinerary.Quantity*0.06*Flight.Price),PST=convert(int,Itinerary.Quantity*0.07*Flight.Price),TotalPrice=convert(int,(Itinerary.Quantity*0.06*Flight.Price)+(Itinerary.Quantity*0.07*Flight.Price)+Flight.Price)
  3. FROM         Flight INNER JOIN
  4.                       Itinerary ON Flight.FlightID = Itinerary.FlightID INNER JOIN
  5.                       Ticket ON Itinerary.TicketID = Ticket.TicketID INNER JOIN
  6.                       Departure ON Flight.DepartureLocationID = Departure.DepartureID INNER JOIN
  7.                       Arrival ON Flight.ArrivalLocationID = Arrival.ArrivalID
  8. WHERE     (Itinerary.ticketid = @Itinerary.ticketid)
this error
Msg 137, Level 15, State 2, Line 9
Must declare the scalar variable "@Itinerary".

Forgive me if remove not the right quotes
Nov 25 '07 #3
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
why is your parameter named "@Itinerary.ticketid"?

I dont know if a . (dot) in the parameter name will be the issue.
Have you tried giving the parameter a name without the dot in it?
maybe soemthing like @ItineraryTicketid ?
Nov 25 '07 #4
dieselxeon
8 New Member
hi
i think i need to tell you what is in my table

i have
customer table, (what is side the table customer info and customerid)
employee table (what is side employee info and employeeid)
ticket table ,(ticketid (PK) ,Cusomerid(FK), employeeid(FK),and date)
itinerary table (TicketID(FK) from ticket table, Flightid(FK) from flight table,class,quantity)
also other table

I think ticket table like order table and Itinerary table like order detail.

right now there is some data in the table ticket and itinerary

Ticket table
ticketid = 1
customerid = 1
employeeid = 1
date= date of ordering

itinerary table
ticketid = 1(samecustomer)
flightid=1(flight to destination A)
class = business
quantity = 1

also it has other which is
ticketid =1 (same customer)
flightid = 2(flight to destination B)
class = business
quantity = 1

mean that the customer buy 2 ticket. so i need to get information from ticket and itinerary table. what i want to display is the value of integer for example:
is say customer id=1 so i need to find who is customerid no from customer table. i can't just put 1 right? becuase i don't know who is customer id no1. Other example it say flight id = 1 i need to know what is in flightid no 1 from flight table there are arrival time , departure time ,date and so on...

Thank you for helping me...
Nov 25 '07 #5
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Hi,
Welsome to TSDN

This seems to be more of a SQL related question than a .Net issue.
I will move the thread to the SQL server forum where Experts there will be able to help you better, and you should get a better response there.

Please do have a look at the Posting Guidelilnes on how to post questions, and how to name your post title so as to recieve a better response and keeping the thread titles crystal clear.

- Shashi
Nov 25 '07 #6
dieselxeon
8 New Member
I am sorry ... and Thank you for telling me because i am new in this forum. Would you mind to tell me the link where i can post my question. Thank you again.
Nov 25 '07 #7
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
I have already moved it to the appropriate forum.
Please take a look at the navigation bar on the top (in blue) which indicates where you are.

with your SQL query, placing a '@' in @Itinerary.ticketid it seems that you requre this value to be passed in by the user / the application.
in which case it is right, In that case, the paramenter name could be anything, but i do not know if the current name violates the way in twhich parameters should be named (something like in C, you cannot have a variable which starts with number or contains dots)

Please try removing the dot in the variable.
Nov 25 '07 #8
dieselxeon
8 New Member
I am sorry about late reply because i just finish working. I just try to remove but it didn't work too.I am not quit undestand which one i have to remove. I am sorry because i am just beginneer.
Nov 26 '07 #9
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
what i mean by removing the dot was to do something like renaming @Itinerary.ticketid to @ItenaryTicketID
Nov 26 '07 #10
dieselxeon
8 New Member
i did that one and still error
Msg 137, Level 15, State 2, Line 9
Must declare the scalar variable "@Itinerary".
Nov 26 '07 #11
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
I did not realise that you do not know how to delclare variables with stored procedure as you had not provided the entire script for it.
Please have a look at this link on how to add paramters to your stored procedure
Nov 26 '07 #12
dieselxeon
8 New Member
You are right about that. i did that one and it works. however, when i try to bind the to listbox in vb form it come again the error travelagencydataset2.itineraryflightreport.fill,ge tdata()couldn't be previewed.
conversion failed when converting the varchar value '@itinerary.ticketid' to data type int.



this one is my store procedure name itineraryflightreport. so that's why i thought something is wrong with my storeprocedure.
so in my vb form i have one text box which is customeridtxbx and listbox. i bind the storeprocedure to listbox so that when i insert my customerid, my list box is going to display the information. My english is not that good please forgive me. let say like this if i put 1 in my textbox in form it will display the info based on my procedure like arrivallocation from table flight and so on. I don't know this is the right link to ask about vb.
Nov 26 '07 #13
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Hi
could you please repost the new SQL storedd procedure script (it should include declarations).
I cannot say whats going on until i see what you have done.
Nov 26 '07 #14
dieselxeon
8 New Member
USE [travelagency]
GO
/****** Object: StoredProcedure [dbo].[itineryfinal] Script Date: 11/25/2007 22:57:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[itineryfinal]
(@ticketid int)
as
SELECT Itinerary.FlightID, Itinerary.Class, Itinerary.Quantity, Ticket.Date, Flight.FlightNo, Flight.AirLine, Flight.DepartureDate, Flight.ArrivalDate,
Flight.DepartureTime, Flight.ArrivalTime, Flight.Price, Departure.DepartureLocation, Arrival.ArrivalLocation,GST=convert(int,Itinerary. Quantity*0.06*Flight.Price),PST=convert(int,Itiner ary.Quantity*0.07*Flight.Price),TotalPrice=convert (int,(Itinerary.Quantity*0.06*Flight.Price)+(Itine rary.Quantity*0.07*Flight.Price)+Flight.Price)
FROM Flight INNER JOIN
Itinerary ON Flight.FlightID = Itinerary.FlightID INNER JOIN
Ticket ON Itinerary.TicketID = Ticket.TicketID INNER JOIN
Departure ON Flight.DepartureLocationID = Departure.DepartureID INNER JOIN
Arrival ON Flight.ArrivalLocationID = Arrival.ArrivalID
WHERE (Itinerary.ticketid = '@Itinerary.ticketid')


is already create in my sql 2005

now i tried to bind to vb form this one "WHERE (Itinerary.ticketid = '@Itinerary.ticketid')" i will refer to my ticketidtxbx in form and the info will display in listbox.


i don't really know how to write the code in vb to execute the storeprocedure to listbox but i know to execute to gridview. first i wrote this code but every time i input 1 in textbox, it didn't display any info ... i think i wrote wrong code please correct me if i am wrong.



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

If orderidtxbx.Text = "" Then
sqlconnection = New SqlConnection("Data Source= xxxxx;Initial Catalog = travelagency; user ID = xxxx; Password = xxxxxxxxx;")
sqlcommand = New SqlCommand("itineraryflightreport", sqlconnection)
sqlcommand.CommandType = CommandType.StoredProcedure

sqldatatable = New Data.DataTable("itineraryflightreport")
Try
sqlconnection.Open()

sqldatareader = sqlcommand.ExecuteReader()
While sqldatareader.Read
ListBox1.Items.Add(sqldatareader.Item("Flight.Flig htNo") & " " & sqldatareader.Item("Flight.AirLine") & " " & sqldatareader.Item("Departure.DepartureLocation") & " " & sqldatareader.Item("Arrival.ArrivalLocation") & " " & sqldatareader.Item("Flight.DepartureDate") & " " & sqldatareader.Item("Flight.ArrivalDate") & " " & sqldatareader.Item("Flight.DepartureTime") & " " & sqldatareader.Item("Flight.ArrivalTime") & " " & sqldatareader.Item("Flight.Price") & " " & sqldatareader.Item("Ticket.Date") & " " & sqldatareader.Item("Itinerary.TicketID") & " " & sqldatareader.Item("Itinerary.FlightID") & " " & sqldatareader.Item("Itinerary.Class") & " " & sqldatareader.Item("Itinerary.Quantity") & " " & sqldatareader.Item("GST = Convert(Int, Itinerary.Quantity * 0.06 * Flight.Price)") & " " & sqldatareader.Item("PST = Convert(Int, Itinerary.Quantity * 0.07 * Flight.Price)") & " " & sqldatareader.Item("TotalPrice = Convert(Int, (Itinerary.Quantity * 0.06 * Flight.Price) + (Itinerary.Quantity * 0.07 * Flight.Price) + Flight.Price)"))
End While

Catch ex As Exception
Debug.WriteLine(ex.Message)

End Try
End If

End Sub




so wrote the second code whic is

Private Sub orderidtxbx_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles orderidtxbx.Click
sqlconnection = New SqlConnection("Data Source= xxxxxx;Initial Catalog = travelagency; user ID = xxxxxxx; Password = xxxxxx;")
sqlcommand = New SqlCommand("select Customer.LastName, Customer.FirstName from customer where ticket.ticketid ='" & orderidtxbx.Text & "'", sqlconnection)

sqlconnection.Open()
sqldatareader = sqlcommand.ExecuteReader()
ListBox1.Items.Add(sqldatareader.Item("LastName") & " " & sqldatareader.Item("FirstName"))


End Sub

i just wrote sort code because i wanted to know is work or not so i select customer latname from customer table and firstname from customer table base on ticket id.

this is the detail again
ticket table in sql
ticket id = 1
customer id = 1 (i need to know who is one so based on ticket id no 1 )so i use join "customer.lastname"
employeid=1
everytime i debug it is say
The multi-part identifier "ticket.ticketid" could not be bound.
i don't know what to do please help me...
Nov 26 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

6
1512
by: Robert | last post by:
Hello, Accessors What I would like to do is create a multi-record table update. I have a table and a form for it. I want to modify it so that there is a new field (textbox) (not bound to a...
0
7202
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
7280
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,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.