Thinus du Pisanie's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
Active Members
Active Posts:
113 (0.08 per day)
Joined:
07-October 11
Profile Views:
3,605
Last Active:
User is offline Jul 08 2015 02:48 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   Thinus du Pisanie has not set their status

Posts I've Made

  1. In Topic: Merging Gridview rows together with the same value in asp.net vb

    Posted 3 Jun 2015

    Ok so I solved it, though it would be nice to post it if someone maybe struggle with the same issue in the future.

    Here is my gridview....

    <table>
    	 <tr>
    	  <td>
    	   <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False"
    	    BorderColor="Black" BorderStyle="Solid" CssClass="grd" DataKeyNames="ID"
    	    DataSourceID="Datasource" EmptyDataText="There are no data records to display." PageSize="5"
    	    Width="900px">
    	    <AlternatingRowStyle CssClass="grdalt" />
    	    <Columns>
    
      <asp:TemplateField HeaderText="Country" Visible="True">
        <ItemTemplate>
         <asp:Label ID="Country" runat="server" Text='<%# Eval("Country")%>'></asp:Label>
        </ItemTemplate>
        </asp:TemplateField>
    
    	    <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-BorderStyle="Solid">
    	    <ItemStyle BorderStyle="Solid" />
    	    </asp:BoundField>
    
    	    <asp:TemplateField>
    	    <ItemTemplate>
    	    <asp:Button ID="cmdcalculate" runat="server" Text="Calculate" CommandArgument='<%# Eval("ID")%>'
    	    CommandName="Calculate" Width="150px" />
    	    </ItemTemplate>
    	    <ItemStyle HorizontalAlign="Center" Width="160px" />
    	    </asp:TemplateField>
    
    	   </Columns>
    
    	   <HeaderStyle CssClass="grdhead" />
    	   <SelectedRowStyle BackColor="#80FFFF" />
    	   </asp:GridView>
    
    	   <asp:SqlDataSource ID="Datasource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
    	   SelectCommand="SELECT ID,Country,Name From Table">  
    	   </asp:SqlDataSource>
    
    	   </td>
    	   </tr>
    	   </table>
    
    


    Here is my code behind..

       Private Sub Gridview1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Gridview1.RowDataBound
            If e.Row.RowType = DataControlRowType.DataRow Then
           
                Dim titleLabel As Label = e.Row.FindControl("Country")
                Dim strval As String = CType(titleLabel, Label).Text
                Dim title As String = ViewState("title")
                If title = strval Then
                    titleLabel.Visible = False
                    titleLabel.Text = String.Empty
                Else
                    title = strval
                    ViewState("title") = title
                    titleLabel.Visible = True
                    titleLabel.Text = "<br><b>" & title & "</b><br>"
                End If
             
            End If
        End Sub
    
    


    Thanks
  2. In Topic: Merging Gridview rows together with the same value in asp.net vb

    Posted 2 Jun 2015

    Ok I found a solution.

    Gridview..

     <table>
      <tr>
       <td>
        <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False"
         BorderColor="Black" BorderStyle="Solid" CssClass="grd" DataKeyNames="ID"
         DataSourceID="Datasource" EmptyDataText="There are no data records to display." PageSize="5"
         Width="900px">
         <AlternatingRowStyle CssClass="grdalt" />
         <Columns>
                                                    
         <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-BorderStyle="Solid">
         <ItemStyle BorderStyle="Solid" />                                                
         </asp:BoundField>
    
         <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-BorderStyle="Solid">
         <ItemStyle BorderStyle="Solid" />
         </asp:BoundField>
                                                  
    
         <asp:TemplateField>
         <ItemTemplate>
         <asp:Button ID="cmdcalculate" runat="server" Text="Calculate" CommandArgument='<%# Eval("ID")%>'
         CommandName="Calculate" Width="150px" />
         </ItemTemplate>
         <ItemStyle HorizontalAlign="Center" Width="160px" />
         </asp:TemplateField>
                                                   
        </Columns>
        <HeaderStyle CssClass="grdhead" />
        <SelectedRowStyle BackColor="#80FFFF" />
        </asp:GridView>
        <asp:SqlDataSource ID="Datasource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                                                
        SelectCommand="SELECT ID,Country,Name From Table">   
      
        </asp:SqlDataSource>
        </td>
        </tr>
        </table>
    
    


    The Code behind..

     Public Sub GridView_Row_Merger(gridView As GridView)
            For rowIndex As Integer = gridView.Rows.Count - 2 To 0 Step -1
                Dim currentRow As GridViewRow = gridView.Rows(rowIndex)
                Dim previousRow As GridViewRow = gridView.Rows(rowIndex + 1)
    
                For i As Integer = 0 To currentRow.Cells.Count - 1
                    If currentRow.Cells(i).Text = previousRow.Cells(i).Text Then
                        If previousRow.Cells(i).RowSpan < 2 Then
                            currentRow.Cells(i).RowSpan = 2
                        Else
                            currentRow.Cells(i).RowSpan = previousRow.Cells(i).RowSpan + 1
                        End If
                        previousRow.Cells(i).Visible = False
                    End If
                Next
            Next
    End Sub
    
    


     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Page.IsPostBack Then
            Else
               Gridview1.DataBind()
               GridView_Row_Merger(Gridview1)
            End If
        End Sub
    
    


    This is the result I get...

    Country--------------Name----------

    USA ---------------Chris---------
    ---------------Jan-----------
    Africa---------------Alta---------- Calculate
    ---------------Abri----------
    China ---------------Lee-----------

    But I want this result...

    Country--------------Name----------

    USA ---------------Chris--------- Calculate
    ---------------Jan----------- Calculate
    Africa---------------Alta---------- Calculate
    ---------------Abri---------- Calculate
    China ---------------Lee----------- Calculate

    Can someone please assist..
  3. In Topic: Compatibility Issues in MS SQL

    Posted 23 Feb 2015

    Oky I am running this now in cmd seems to be working I will let you know if it works.

    sqlcmd -S localhost -i C:\script.sql
  4. In Topic: Automatic birthday email send out of MS SQL

    Posted 28 Jul 2014

    Ok i figured it out :donatello:

    USE [Customers]
    GO
    
    SET ANSI_NULLS ON
    
    GO
    
    SET QUOTED_IDENTIFIER ON
    
    GO
    ALTER PROCEDURE [dbo].[EmailData]
    
    AS
    
    Declare @email        nvarchar(128)
    Declare @name         nvarchar(128)
    Declare @Date         date
    
    SELECT GETDATE(), Month(GetDate()), Day(GetDate()), Year(GetDate())
    
    DECLARE rcpt_cursor CURSOR FOR 
    select
           a.Name,
           b.Email 
        from dbo.Customers  a
            inner join dbo.Customers b
            on a.Manager = b.ID
    where Month(a.BirthDate) = Month(GetDate())
        and Day(a.BirthDate) = Day(GetDate())
    
    OPEN rcpt_cursor
    
    FETCH NEXT FROM rcpt_cursor
    
    
    INTO @name,@email
    
    WHILE @@FETCH_STATUS = 0
    
    BEGIN
    PRINT @email
    Declare @subject nvarchar(255)
    Declare @Bodytext nvarchar(512)
    
    Set @BodyText = @Name + '' + ' has a birthday today. Please congrad him'
    Set @Subject = 'Employee Birthday' 
    
    exec msdb.dbo.sp_send_dbmail
    @Profile_Name = 'HappyBirthday',
    @Recipients = @email,
    @Body = @BodyText,
    @Subject = @Subject
    
    FETCH NEXT FROM rcpt_cursor
    INTO @name,@email
    
    
    END 
    
    CLOSE rcpt_cursor
    
    DEALLOCATE rcpt_cursor
    
    Go 
    
    Exec [EmailData]
    
  5. In Topic: Automatic birthday email send out of MS SQL

    Posted 25 Jul 2014

    Ok this is what I got

    Alter PROCEDURE EmailData
    
    AS
    BEGIN
    
    Declare @email             nvarchar(128)
    Declare @Date              date
    
    SELECT GETDATE(), Month(GetDate()), Day(GetDate()), Year(GetDate())
    
    DECLARE rcpt_cursor CURSOR FOR 
    select 
           b.Email
           from dbo.Customers  a
           inner join dbo.Customers b
           on a.Manager = b.ID
    where Month(a.BirthDate) = Month(GetDate())
          and Day(a.BirthDate) = Day(GetDate())
    
    OPEN rcpt_cursor
    
    FETCH NEXT FROM rcpt_cursor INTO @email
    
    DECLARE @ServerAddr nvarchar(128)
    Set @ServerAddr = 'smtp.gmail.com'
    
    DECLARE @From nvarchar(128)
    Set @From = 'My Email Address'
    
    DECLARE @Bodytext nvarchar(512)
    Set @BodyText = 'Your Employees have a birthday today.'
    
    DECLARE @User nvarchar(128)
    Set @User = 'My Email Address'
    
    DECLARE @Password nvarchar(128)
    Set @Password = 'My Password'
    
    DECLARE @SSL int
    Set @SSL = 0
    
    DECLARE @Port int
    Set @Port = 587
    
    WHILE @@FETCH_STATUS = 0
    BEGIN
    PRINT @email
    DECLARE @subject nvarchar(255)
    SELECT @Subject = 'Happy Birthday' +  @email
    EXEC EmailData @ServerAddr, 
        @from, @email, @subject, @BodyText, @User, @Password, @SSL, @Port
    FETCH NEXT FROM rcpt_cursor
    INTO @email
    END
    CLOSE rcpt_cursor
    DEALLOCATE rcpt_cursor
    
    End
    Go 
    


    When I execute it I get Command(s) completed successfully. But I don't get the emails and I don't understand why. Is there somewhere where there will be a log to show why this is happening?

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

Thinus du Pisanie hasn't added any friends yet.

Comments

Thinus du Pisanie has no profile comments yet. Why not say hello?