Programming for Everybody: December 2017

How to sum gridview column values dynamically in vb.net?

Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound
        Dim Volume As Decimal = 0
        For Each r As GridViewRow In GridView1.Rows
            If r.RowType = DataControlRowType.DataRow Then
                Volume += Convert.ToDecimal(r.Cells(1).Text)
            End If
        Next
        total1.Text = Math.Round(Volume, 0).ToString()
    End Sub

How to count the rows in a gridview asp.net vb.net

Solution
 Dim aa As Integer = GridView1.Rows.Count
            Label44.Text = aa

Auto Generate Row Number in GridView asp.net

Solution

 <asp:TemplateField HeaderText="No.">
                        <ItemTemplate>
                            <%# Container.DataItemIndex + 1 %>
                        </ItemTemplate>
                        <ItemStyle Width="25px" />
                    </asp:TemplateField>

datetime format in asp.net gridview

 Solution
  <asp:boundfield datafield="date_birth" dataformatstring="{0:dd/MM/yyyy}"
                    HeaderText="Date of Birth" htmlencode="false" SortExpression="date_birth">
                <ItemStyle Width="100px" />
                </asp:boundfield>

get current system date ASP.net

Solution
 mdate_v = "'" & DateTime.Now().Year & "-" & DateTime.Now().Month & "-" & DateTime.Now().Day & "'"

display date in (dd/mm/yyyy) format using Label ASP.net

 Solution

Dim date2_v As String = Format(Me.date2.Text.ToString, "yyyy/MM/dd")

incorrect syntax near '=' ASP.net




objconnectionins1 = New SqlConnection("Data Source=.\;Initial Catalog=format1;Integrated Security=True")
                objconnectionins1.Open()

                Dim strsql As String
        strsql = " select * from table1  where id=" + textbox1.Text + ""
                Dim objcommand As New SqlCommand(strsql, objconnectionins1)

                myreader = objcommand.ExecuteReader()
                myreader.Read()

        lblDisplay.Text = myreader("content1")
               

        label2.Text = myreader("content")
       


        objconnectionins1.Close()
        lblDisplay.Visible = True

Solution

objconnectionins1 = New SqlConnection("Data Source=.\;Initial Catalog=format1;Integrated Security=True")
                objconnectionins1.Open()

                Dim strsql As String
        strsql = " select * from table1  where id='" + textbox1.Text + "'"
                Dim objcommand As New SqlCommand(strsql, objconnectionins1)

                myreader = objcommand.ExecuteReader()
                myreader.Read()

        lblDisplay.Text = myreader("content1")
               

        label2.Text = myreader("content")
       


        objconnectionins1.Close()
        lblDisplay.Visible = True




    End Sub

SQL SELECT WHERE field contains words and Specific value

 SQL SELECT WHERE field contains words
SELECT     n1, title, address
FROM         pages
WHERE     (
title LIKE '%Morad%') 

Specific value
 
SELECT     n1, title, address
FROM         pages
WHERE     (
title= 'Morad Gamal')

generate auto number in sql server 2008

 1 -  Choose (int) data type-
2 -  in Column properties  >>>press + identity specification
3 - Is identity >>>> choose YES

Sql Server 'Saving changes is not permitted' error

To change this option, on the Tools menu, click Options, expand Designers, and then click Table and Database Designers. Select or clear the Prevent saving changes that require the table to be re-created check box.

Visual Basic 2010 add Windows Media Player Tool

from toolbox >>>click right Menustrip >>>com components>>>>Windows Mediaplayer

لمعرفة IP adress جهازك

1 - نضغفط على قائمة Start
2 - Run
3 - CMD
4 - Ipconfig

كيفية فتح منفذ sql في Firewall



إصلاح المشكلة بنفسي

1.       تشغيل "المفكرة".

1.       نسخ ولصق التعليمات البرمجية التالية في "المفكرة": 

2.  netsh advfirewall firewall add rule name="Open Port 80" dir=in action=allow protocol=TCP localport=80
3.   
4.  @echo =========  SQL Server Ports  ===================
5.  @echo Enabling SQLServer default instance port 1433
6.  netsh advfirewall firewall add rule name="SQL Server" dir=in action=allow protocol=TCP localport=1433
7.  @echo Enabling Dedicated Admin Connection port 1434
8.  netsh advfirewall firewall add rule name="SQL Admin Connection" dir=in action=allow protocol=TCP localport=1434
9.  @echo Enabling Conventional SQL Server Service Broker port 4022
10. netsh advfirewall firewall add rule name="SQL Service Broker" dir=in action=allow protocol=TCP localport=4022
11. @echo Enabling Transact SQL/RPC port 135
12. netsh advfirewall firewall add rule name="SQL Debugger/RPC" dir=in action=allow protocol=TCP localport=135
13. @echo =========  Analysis Services Ports  ==============
14. @echo Enabling SSAS Default Instance port 2383
15. netsh advfirewall firewall add rule name="Analysis Services" dir=in action=allow protocol=TCP localport=2383
16. @echo Enabling SQL Server Browser Service port 2382
17. netsh advfirewall firewall add rule name="SQL Browser" dir=in action=allow protocol=TCP localport=2382
18.  
19. @echo =========  Misc Applications  ==============
20. @echo Enabling HTTP port 80
21. netsh advfirewall firewall add rule name="HTTP" dir=in action=allow protocol=TCP localport=80
22. @echo Enabling SSL port 443
23. netsh advfirewall firewall add rule name="SSL" dir=in action=allow protocol=TCP localport=443
24. @echo Enabling port for SQL Server Browser Service's 'Browse' Button
25. netsh advfirewall firewall add rule name="SQL Browser" dir=in action=allow protocol=UDP localport=1434
26. @echo Allowing multicast broadcast response on UDP (Browser Service Enumerations OK)
netsh firewall set multicastbroadcastresponse ENABLE
27.   حفظ الملف كملف.txt باستخدام الاسم التالي: OpenSqlServerPort.txt
28.   إعادة تسمية الملف OpenSqlServerPort.txt لما يلي: OpenSqlServerPort.bat


قبل تشغيل البرنامج النصي OpenSqlServerPort.bat، يجب نسخ البرنامج النصي للكمبيوتر يحتوي على جدار الحماية وقم بتشغيل البرنامج النصي على ذلك الكمبيوترلتشغيل البرنامج النصي، اتبع الخطوات التالية:
1.       انقر فوق ابدأ، ثم انقر فوق تشغيل، واكتب cmdوثم انقر فوق موافق.
2.       في موجه الأوامر، استخدم الأمر cd للانتقال إلى المجلد الذي تم حفظ الملف OpenSqlServerPort.bat.
3.       لتشغيل البرنامج النصي OpenSqlServerPort.bat واكتب OpenSqlServerPort.bat في موجه الأوامر ثم اضغط Enter.