Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a some image buttons

eg:-

for a bus i have created some seats for image button

seat-1
seat-2
seat-3
.
.
.
.
.
seat-50

whenever user clicks an image it changes it colour i.e another image

and seat numbers get poplutated in list box

what i need is
create a database where each seat saves as 1 else 0 from listbox

then

check from database where seat is booked i.e seat_1 is 1 then image should be changed when page load.

please help
Posted
Updated 1-May-12 21:23pm
v4
Comments
OriginalGriff 2-May-12 2:50am    
And what is your problem?
Where are you stuck?
Which bit can't you do?
mani.kishore.asp.net 2-May-12 2:52am    
1) saving the list box data to sql
2) retreving the data from sql where seat_1 of a particular table value is 1 then imageurl="...........jpg"
for all buttons

mani.kishore.asp.net 2-May-12 3:17am    
my data base structure is like this

emp_no int
date varchar
time varchar
seat_1 bit
seat_2 bit
seat_3 bit
.
.
.
.
seat_50 bit


asp code is

seat_1 imageurl=".....jpg"

seat_1_onclick
imageurl=".....jpg"

1) saving the list box data to sql
2) retreving the data from sql where seat_1 of a particular table value is 1 then imageurl="...........jpg"
for all buttons
bbirajdar 2-May-12 5:33am    
Reason for my vote of 1
Homework

1 solution

This could take a while, So I'll move it into an answer:

1) saving the list box data to sql
2) retreving the data from sql where seat_1 of a particular table value is 1 then imageurl="...........jpg"
for all buttons



The first thing you need to do is create your Database: Have you done that? If so, what table(s) and column(s) have you defined? What types are they?

Then you need to look at how you access the database: the simplest way is to have a reader in a loop:
VB
Using con As New SqlConnection(strConnect)
	con.Open()
	Using com As New SqlCommand("SELECT iD, description FROM myTable", con)
		Using reader As SqlDataReader = com.ExecuteReader()
			While reader.Read()
				Dim id__1 As Integer = CInt(reader("iD"))
				Dim desc As String = DirectCast(reader("description"), String)
				Console.WriteLine("ID: {0}" & vbLf & "    {1}", iD, desc)
			End While
		End Using
	End Using
End Using
(That is only an example - it won't do what you want!)
Then you can look at saving data - but the first thing to do is sort out what data you are going to use.


"my data base structure is like this"

emp_no  int
date    varchar
time    varchar
seat_1  bit
seat_2  bit
seat_3  bit
...
seat_50 bit


You would have to modify the SELECT statement, but to read an individual seat:
VB
Dim seat_1 As Boolean = reader.GetBoolean(reader.GetOrdinal("seat_1"))


You can then use that bool directly to assign one of two images to the button:
VB
buttonSeat1.Image = If(seat_1, redSeat, blueSeat)
 
Share this answer
 
v2
Comments
mani.kishore.asp.net 2-May-12 3:18am    
my data base structure is like this

emp_no int
date varchar
time varchar
seat_1 bit
seat_2 bit
seat_3 bit
.
.
.
.
seat_50 bit


asp code is

seat_1 imageurl=".....jpg"

seat_1_onclick
imageurl=".....jpg"

1) saving the list box data to sql
2) retreving the data from sql where seat_1 of a particular table value is 1 then imageurl="...........jpg"
for all buttons

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900