justnew
04-13-2005, 02:53 PM
Help with Passing 2 Parameters at the same time
I want to display product Image and the info about the product at the same time. Right now I am using 2 hyperlink_columns. The first one is for ProductInfo the NavigateUrl is: ViewImage.aspx?ProductID={0} and the other hyperlinkcolumn as ViewImage.aspx?ImageID={0} .Can somebody help me so that I can pass both ProductID and ImageID at the same time . I would like to display both the Product Info and the Image at the same time. My codes are shown below. Thanks in advance
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
ProductID = Request.QueryString("ProductID")
ProductInfo()
DisplayImages(Request.QueryString("ImageID"))
End Sub
Public Function DisplayImages(ByVal ImageID As Integer) As DataSet
Dim SqlConnection1 As New System.Data.SqlClient.SqlConnection
Dim SQL As String
Dim ProdSql As String
Dim bmpFile As Bitmap
Dim stmFile As New MemoryStream
Dim objWriter As New _
BinaryWriter(stmFile)
Dim myCommand As New SqlClient.SqlCommand
Dim myReader As SqlClient.SqlDataReader
SqlConnection1.ConnectionString = ConnectionString
SQL = "Select LGimgdata,LGimgcontenttype from Product_Image where ImageID=" & ImageID
myCommand.CommandText = SQL
myCommand.Connection = SqlConnection1
SqlConnection1.Open()
myReader = myCommand.ExecuteReader()
While myReader.Read
objWriter.Write( _
myReader("Lgimgdata"))
bmpFile = New Bitmap(stmFile)
Response.ContentType = myReader("Lgimgcontenttype")
Dim thisformat = bmpFile.RawFormat
bmpFile.Save(Response.OutputStream, thisformat)
End While
myReader.Close()
SqlConnection1.Close()
End Function
Public Function GetProductID(ByVal ProductId As Integer) As DataSet
Dim SQL as String
SQL= "SELECT Seller.Fname,Seller.Phone, Seller.Email,Seller.Town,Product.Product, Product.SellerID,Product.Descriptions, Product.Price FROM Product INNER JOIN Seller ON Product.SellerID = Seller.SellerID where ProductID=" & ProductId
Dim connString As String = "Server=mysqlserver; Initial Catalog=mydb; UID=myUID; Password=mypwd; Network Library=dbmssocn;"
Dim conn As SqlConnection = New SqlConnection(connString)
Dim da As SqlDataAdapter = New SqlDataAdapter(SQL, conn)
Dim ds As DataSet = New DataSet
conn.Open()
Try
da.Fill(ds)
Return ds
Catch e As SqlException
Throw (e)
Finally
conn.Close()
End Try
End Function
Public Sub ProductInfo()
'Dim connString As String = "Server="Server=mysqlserver; Initial Catalog=mydb; UID=myUID; Password=mypwd; Network Library=dbmssocn;"
ds = GetProductID(ProductID)
lblsel.Visible = False
If ds.Tables(0).Rows.Count > 0 Then
datarad = ds.Tables(0).Rows(0)
lblfname.Text = datarad.Item(0)
lblphone.Text = datarad.Item(1)
End If
End Sub
I want to display product Image and the info about the product at the same time. Right now I am using 2 hyperlink_columns. The first one is for ProductInfo the NavigateUrl is: ViewImage.aspx?ProductID={0} and the other hyperlinkcolumn as ViewImage.aspx?ImageID={0} .Can somebody help me so that I can pass both ProductID and ImageID at the same time . I would like to display both the Product Info and the Image at the same time. My codes are shown below. Thanks in advance
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
ProductID = Request.QueryString("ProductID")
ProductInfo()
DisplayImages(Request.QueryString("ImageID"))
End Sub
Public Function DisplayImages(ByVal ImageID As Integer) As DataSet
Dim SqlConnection1 As New System.Data.SqlClient.SqlConnection
Dim SQL As String
Dim ProdSql As String
Dim bmpFile As Bitmap
Dim stmFile As New MemoryStream
Dim objWriter As New _
BinaryWriter(stmFile)
Dim myCommand As New SqlClient.SqlCommand
Dim myReader As SqlClient.SqlDataReader
SqlConnection1.ConnectionString = ConnectionString
SQL = "Select LGimgdata,LGimgcontenttype from Product_Image where ImageID=" & ImageID
myCommand.CommandText = SQL
myCommand.Connection = SqlConnection1
SqlConnection1.Open()
myReader = myCommand.ExecuteReader()
While myReader.Read
objWriter.Write( _
myReader("Lgimgdata"))
bmpFile = New Bitmap(stmFile)
Response.ContentType = myReader("Lgimgcontenttype")
Dim thisformat = bmpFile.RawFormat
bmpFile.Save(Response.OutputStream, thisformat)
End While
myReader.Close()
SqlConnection1.Close()
End Function
Public Function GetProductID(ByVal ProductId As Integer) As DataSet
Dim SQL as String
SQL= "SELECT Seller.Fname,Seller.Phone, Seller.Email,Seller.Town,Product.Product, Product.SellerID,Product.Descriptions, Product.Price FROM Product INNER JOIN Seller ON Product.SellerID = Seller.SellerID where ProductID=" & ProductId
Dim connString As String = "Server=mysqlserver; Initial Catalog=mydb; UID=myUID; Password=mypwd; Network Library=dbmssocn;"
Dim conn As SqlConnection = New SqlConnection(connString)
Dim da As SqlDataAdapter = New SqlDataAdapter(SQL, conn)
Dim ds As DataSet = New DataSet
conn.Open()
Try
da.Fill(ds)
Return ds
Catch e As SqlException
Throw (e)
Finally
conn.Close()
End Try
End Function
Public Sub ProductInfo()
'Dim connString As String = "Server="Server=mysqlserver; Initial Catalog=mydb; UID=myUID; Password=mypwd; Network Library=dbmssocn;"
ds = GetProductID(ProductID)
lblsel.Visible = False
If ds.Tables(0).Rows.Count > 0 Then
datarad = ds.Tables(0).Rows(0)
lblfname.Text = datarad.Item(0)
lblphone.Text = datarad.Item(1)
End If
End Sub