Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 29th, 2004, 09:33 AM
Authorized User
 
Join Date: Oct 2003
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Default commandtext-sql

Hi,

Not sure this is the right place to ask my question but i will try.



I have a dg that gets populated from the db. I have an image column that received a default -nopict.gif if the db ad_image field is empty. If it isn't empty then the dg shows a thumbnail of the image. Everything till here works great.
Now i have added an option that the user can upload a htm/l file. If in the db the ad_image field contains a htm/l extension then i want the dg to display the image -html.gif from the image file. I have no idea how to write my code to do that.

Thanks in advance.

Below is my aspx.vb code:

    Sub fillTable()

        If Page.IsPostBack Then
            Add_AD.Visible = True

            Dim ad_id As String

            Dim u_id As String
            u_id = txtUID.Value.Trim
            ad_id = txtAdId.Value.Trim
            cmd = oConn.CreateCommand

 cmd.CommandText = "select *,CASE AD_IMAGE WHEN '' THEN 'nopict.gif' ELSE AD_IMAGE END AS AD_IMGNAME, 'adDetail.aspx?sid=' + @sid + '&ad_id=' + CAST(ad_id AS NVARCHAR(16))+ '&sub_id=' + CAST(sub_id AS NVARCHAR(16))+ '&cat_id=' + CAST(cat_id AS NVARCHAR(16)) AS url_str FROM ybay_mdb...ads WHERE ad_poster like '%'+@U_ID+'%' AND AD_ID like '%'+@AD_ID+'%'"

            cmd.Parameters.Add("@U_ID", u_id)
            cmd.Parameters.Add("@AD_ID", ad_id)
            cmd.Parameters.Add("@sid", sid)
            Dim da As New SqlDataAdapter(cmd)
            Dim dt As New DataTable("ADS")
            da.Fill(dt)
            DataGrid1.DataSource = dt
            DataGrid1.DataBind()

            If dt.Rows.Count = 0 Then
                DataGrid1.Visible = False
                Label1.Visible = True
            Else
                DataGrid1.Visible = True
                Label1.Visible = False
            End If

            'oConn.Open()
            'Dim dr As SqlDataReader
            'dr = cmd.ExecuteReader

            'Do While dr.Read
            ' AD_IMGNAME = dr.Item("AD_IMGNAME")


            'Dim s0 As String
            's0 = AD_IMGNAME.Split(".")(1)
            'If s0 = "html" Or s0 = "htm" Then
            ' AD_IMGNAME = "html.gif"
            ' Response.Write(AD_IMGNAME)

            ' End If
            'Loop
            'oConn.Close()
        End If
    End Sub
    Sub doPaging(ByVal s As Object, ByVal e As DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
        DataGrid1.CurrentPageIndex = e.NewPageIndex

        fillTable()
    End Sub


    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        fillTable()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Response.Redirect("Manage_Users.aspx?sid=" & sid)

    End Sub

The aspx dg part where i load the image:
<ItemTemplate>
<Img src="http://www.mysite.co.il/images/<%#Container.DataItem("AD_IMGNAME") %>" id="img" height="50" width="50">
</ItemTemplate>

 
Old January 29th, 2004, 03:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You may need to make the image a server control, so that you can manipulate the ImageURL property of the image control. You could make the modification through a string manipulation.

I'm not sure if I'm on the right track; if not, let me know.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
can't set CommandText property if cache has >1 rpt ashortxl Excel VBA 10 May 16th, 2014 10:53 AM
How Run .sql Script file in MS SQL Server 2000? aarkaycee SQL Server 2000 5 October 12th, 2009 05:43 AM
Converting from MS SQL 2005 to Sql Epress edition saif44 SQL Language 0 February 16th, 2007 04:17 PM
Failed to copy objects from SQL server to SQL Serv monfu SQL Server 2000 4 December 4th, 2005 05:54 PM
Move SQL DB from one sql to another sql server Israr SQL Server 2000 3 January 24th, 2005 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.