Google Mobile Ads

Thursday, September 12, 2013

MD5 - SHA1- SHA256 - SHA512 ile string bir değeri şifrelemek.

MD5 - SHA1- SHA256 - SHA512 ile string bir değeri şifrelemek.

Combobox - cbAlgorithms
txtValue - TextBox
txtResult - TextBox(Multiline=true)
btnEncrypt - Button

Imports System.Text
Imports System.Security.Cryptography
Public Class frmMain

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cbAlgorithms.Items.Add("Seçiniz...")
        cbAlgorithms.Items.Add("MD5")
        cbAlgorithms.Items.Add("SHA1")
        cbAlgorithms.Items.Add("SHA256")
        cbAlgorithms.Items.Add("SHA512")
        cbAlgorithms.SelectedIndex = 0
    End Sub

    Public Function EncryptMD5(ByVal ClearString As String) As String
        Dim uniEncode As New UnicodeEncoding()
        Dim bytClearString() As Byte = uniEncode.GetBytes(ClearString)
        Dim md5 As New MD5Cng
        Dim hash() As Byte = md5.ComputeHash(bytClearString)

Monday, August 12, 2013

"The test form is only available for requests from the local machine."

Kendi makinenizde oluşturduğunuz bir web servisi, web sunucuya yüklediğinizde "The test form is only available for requests from the local machine." uyarısı ile karşılaşabilirsiniz. Bu durumda yapmanız gereken web.config dosyasında <system.web> tag lerinin arasına, aşağıdaki <webServices>.....</webServices> tag bloğunu yerleştirmeniz.

<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>

Monday, August 5, 2013

Türkiye Vergi Daireleri Listesi 2013 SQL

Metin dosyası olarak paylaşamadığım için kusura bakmayın.

CREATE TABLE [dbo].[t_VergiDaireleri](
[VDID] [int] NULL,
[PlakaKodu] [varchar](3) NULL,
[IlAdi] [nvarchar](50) NULL,
[IlceAdi] [nvarchar](100) NULL,
[VergiDairesiAdi] [nvarchar](255) NULL
) ON [PRIMARY]

INSERT [t_VergiDaireleri] ([VDID], [PlakaKodu], [IlAdi], [IlceAdi], [VergiDairesiAdi]) VALUES (1, N'01', N'ADANA', N'Merkez', N'5 Ocak Vergi Dairesi Müdürlüğü')
INSERT [t_VergiDaireleri] ([VDID], [PlakaKodu], [IlAdi], [IlceAdi], [VergiDairesiAdi]) VALUES (2, N'01', N'ADANA', N'Merkez', N'Yüreğir Vergi Dairesi Müdürlüğü')
INSERT [t_VergiDaireleri] ([VDID], [PlakaKodu], [IlAdi], [IlceAdi], [VergiDairesiAdi]) VALUES (3, N'01', N'ADANA', N'Merkez', N'Seyhan Vergi Dairesi Müdürlüğü')

Friday, July 19, 2013

VB.NET Excel Number Format

Excel sheetindeki belirli bir yerin number formatı nasıl değiştirilir.

wSheet.Range("A2:A100").NumberFormat = "dd/MM/yyyy"
wSheet.Range("A2:A100").NumberFormat = "#,##0.00"

Wednesday, July 10, 2013

Visual Studio: Useful Keyboard Shortcuts

CTRL + M + O will collapse all.
CTRL + M + L will expand all.
CTRL + M + P will expand all and disable outlining.
CTRL + M + M Collapse / un-collapse current preset area (e.g. method)
CTRL + F6 / CTRL + Shift + F6 Go to next / go to previous window

Monday, June 17, 2013

VB.NET Combobox CopyTo Array

Bir combobox'tan diğer combobox'a verilerin kopyalanması (myComboBox1 -> myComboBox2)

        Dim myArray(myComboBox1.Items.Count - 1) As String
        myComboBox1.Items.CopyTo(myArray, 0)
        myComboBox2.Items.AddRange(myArray)

VB.NET ToUpper() fonksiyonu içinde CultureInfo kullanmak

        Dim uStr As String
        Dim str As String = "iıu"
        uStr = str.ToUpper(New CultureInfo("en-US", False))   'returns IIU

Thursday, June 6, 2013

SQL Server'da log dosyasını shrink etmek (kesin çözüm)

SQL Server'da veritabanı ve log dosyasını shrink etmek (Kesin Çözüm)

ALTER DATABASE VeritabaniAdi SET RECOVERY SIMPLE 
GO
DBCC SHRINKDATABASE  ( 'VeritabaniAdi', 0 )
GO
ALTER DATABASE VeritabaniAdi  SET RECOVERY FULL 

Wednesday, June 5, 2013

VB.NET'te windows schedule ekleme

VB.NET'te windows schedule ekleme

Dim JobID As String = "Test"
Dim mgmtClass As New ManagementClass("Win32_ScheduledJob")
Dim methodArgs(6) As Object 'seven arguments
methodArgs(0) = "Notepad.exe"
methodArgs(1) = "********143000.000000-420"
methodArgs(2) = True
methodArgs(3) = 1 Or 4 Or 16 'days of the week? 
methodArgs(4) = Nothing
methodArgs(5) = True
Methodargs(6) = JobID
'Execute the method
Dim errorNum As Integer = mgmtClass.InvokeMethod("Create", methodArgs)
MsgBox(errorNum) 'Zero means success. 



http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/04eca99a-d167-4388-b010-7d5ded0da86e/

http://msdn.microsoft.com/en-us/library/aa394399(VS.85).aspx

Monday, June 3, 2013

VB.NET'de dosya adı değiştirmek

VB.NET'de dosya adı değiştirmek

My.Computer.FileSystem.RenameFile("c:\foldername\test.txt", "test2.txt")

Sunday, May 26, 2013

Transact-SQL: DATETIME tipindeki veriden saat bilgisi olmadan sadece DATE kısmını almak.

SELECT (CAST(YEAR([Date]) AS VARCHAR(4)) + '-' + RIGHT('00' + CAST(MONTH([Date]) AS VARCHAR(2)),2) + '-' + RIGHT('00' + CAST(DAY([Date]) AS VARCHAR(2)),2)) AS [strDate], * FROM appointment

SELECT CONVERT(DATE, CAST([Date] AS VARCHAR), 120) AS [strDate], * FROM appointment

Friday, May 24, 2013

VB.NET: ListView HitTest Kullanımı

ListViewHitTestInfo Kullanımı

    Private Sub ListView1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Right Then
            Dim ht As ListViewHitTestInfo = ListView1.HitTest(New Point(e.X, e.Y))
            MessageBox.Show(ht.Item.Index.ToString & " - " & ht.SubItem.Text)
        End If
    End Sub

Transact SQL : OUTPUT Clause


OUTPUT Clause
OUTPUT ile eklenen, silinen ve güncelleme yapılan tablolardaki hareketleri sadece sayısal değil değerleri ile birlikte gözlemleyebiliriz. 

MSDN açıklaması:
Returns information from, or expressions based on, each row affected by an INSERT, UPDATE, or DELETE statement. These results can be returned to the processing application for use in such things as confirmation messages, archiving, and other such application requirements. Alternatively, results can be inserted into a table or table variable.
USE tempdb
go

CREATE TABLE table1
(
    id INT,
    employee VARCHAR(32)
)
go

INSERT INTO table1 VALUES(1, 'Fred')
INSERT INTO table1 VALUES(2, 'Tom')
INSERT INTO table1 VALUES(3, 'Sally')
INSERT INTO table1 VALUES(4, 'Alice')
GO

VB.NET ile SQL Server'a Bağlanmak.

VB.NET ile SQL Server'a bağlanmak ve sorgu sonucunu datatable'a atmak.

'Imports System.Data.SqlClient
Dim con As New SqlClient.SqlConnection Dim strCon As String = "Data Source=SERVERNAME;Initial Catalog=DATABASENAME;Integrated Security=SSPI;Connection Timeout=10;" 'NT Authentication 'For SQL Authentication Dim strCon As String = "Data Source=SERVERNAME;Initial Catalog=DATABASENAME;User ID=USERNAME;Password=PASSWORD;Connection Timeout=50;" Dim strCommand As String = "SELECT * FROM TABLE" Dim command As SqlCommand Dim da As SqlDataAdapter Dim dt As New DataTable Try con.ConnectionString = strCon command = New SqlCommand(strCommand, con) command.CommandTimeout = 3000
da = New SqlDataAdapter(command) da.Fill(dt) MsgBox(dt.Rows.Count.ToString())
'FOR INSERT, UPDATE, DELETE, USE BELOW
'Dim count as Integer = command.ExecuteNonQuery()
'count is the affected row number
Catch ex As Exception MessageBox.Show(ex.Message, "Error") Finally If con.State = ConnectionState.Open Then con.Close() End If End Try

SQL SERVER'da bir kolonun adını değiştirmek.

Herhangi bir kolonun adını değiştirmek için,
sp_RENAME 'TableName.[OldColumnName]' '[NewColumnName]''COLUMN'
Herhangi bir nesnenin adını değiştirmek için (table, sp vs.) :
sp_RENAME '[OldTableName]' '[NewTableName]'

Tuesday, May 21, 2013

SQL Server 2012 Sertifikasyon Sınavları

SQL Server 2012 Sertifikasyon Sınavları

MCSA: SQL Server

Solutions Associate


70-461 -> Querying Microsoft SQL Server 2012
70-462 -> Administering Microsoft SQL Server 2012 Databases
70-463 -> Implementing a Data Warehouse with Microsoft SQL Server 2012

Tuesday, May 14, 2013

VB.NET DataTable oluşturmak ve satır eklemek


Yeni datatable oluşturma:
Dim dtResult As New DataTable

Kolonları oluşturma
If dtResult.Columns.Count = 0 Then
dtResult.Columns.Add("TCKimlikNo", Type.GetType("System.Double"))
dtResult.Columns.Add("Adi", Type.GetType("System.String"))
dtResult.Columns.Add("Soyadi", Type.GetType("System.String"))
dtResult.Columns.Add("DogumYili", Type.GetType("System.Int32"))
End If

Oluşturduğumuz datatable'a satır ekleme:

Wednesday, May 1, 2013

User Control içinde TextBox'ın Text property sini override etmek.


User Control içinde TextBox'ın Text property sini override etmek.

Imports System.ComponentModel

    <EditorBrowsable(EditorBrowsableState.Always)> _
    <Browsable(True)> _
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    <Bindable(True)> _
    Public Overrides Property Text() As String
        Get
            Return TextBox1.Text
        End Get
        Set(ByVal value As String)
            TextBox1.Text = value
        End Set
    End Property

Thursday, April 25, 2013

VB.NET Datatable'daki veriyi sıralamak.

Datatable'daki veriyi, SQL'deki Order By deyimini kullanıyormuş gibi sıralamak.

myDataTable.DefaultView.Sort = "columnName DESC"

ya da LinQ kullanarak

Dim linQuery = (From dRow In myDataTable.AsEnumerable() _
                Order By dRow.Item(columnName) Descending)
myDataTable = linQuery.CopyToDataTable()

Wednesday, April 17, 2013

SQL'de Split Fonksiyonu


SQL'de Split Fonksiyonu

ALTER FUNCTION [dbo].[fn_Split](@text varchar(8000), @delimiter varchar(20) = ' ')
RETURNS @Strings TABLE
(
  Split VarChar(1000)
)
AS
BEGIN
DECLARE @index int
SET @index = -1
WHILE (LEN(@text) > 0)
  BEGIN 
    SET @index = CHARINDEX(@delimiter , @text) 
    IF (@index = 0) AND (LEN(@text) > 0) 
      BEGIN  
        INSERT INTO @Strings VALUES (@text)
          BREAK 

SQL'de bir tabloya index ekleme ve bu eklenen index'e göre tabloyu rebuild etme


Bir tabloya index ekleme ve bu eklenen index'e göre tabloyu rebuild etme

IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[t_Products]') AND name = N'x_Products_venderno')
DROP INDEX [x_Products_venderno] ON [dbo].[t_Products] WITH ( ONLINE = OFF )
GO

CREATE NONCLUSTERED INDEX [x_Products_venderno] ON [dbo].[t_Products] 
(
[ds_id] ASC,
[vender_no] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO


ALTER INDEX x_Products_venderno ON [dbo].[t_Products]
REBUILD;

Friday, March 29, 2013

ListView'e DataTable'dan veri aktarmak.


ListView'e DataTable'dan veri aktarmak. Aşağıdaki kodu kullanmadan önce, listView'de str dizisine aktarılan her veri için bir kolon oluşturulması gerekmektedir.
For i As Integer = 0 To myDataTable.Rows.Count - 1
    Dim str(4) As String
    Dim itm As ListViewItem
    str(0) = myDataTable.Rows(i)("userID")    str(1) = myDataTable.Rows(i)("Name")    str(2) = myDataTable.Rows(i)("SurName")    str(3) = myDataTable.Rows(i)("Genre")    str(4) = myDataTable.Rows(i)("Country")    itm = New ListViewItem(str)
    listView.Items.Add(itm)
Next

Tuesday, March 26, 2013

.NET TabControl içinde istenen sayfaya gitmek.

TabControl içinde sayfalar arasında geçişi sağlamak ya da tabcontrol içindeki bir sayfaya erişimi engellemek için aşağıdaki kod parçası kullanılabilir(bu durumda tabcontrol'un SelectedIndexChanged event'inde belirtilmelidir).

TabControl.SelectedTab

Kullanımı:
tabControl1.SelectedTab = tabControl1.TabPages(1)

Thursday, March 21, 2013

RSAPKCS1SHA256SignatureDescription in VB.NET


Imports System
Imports System.Security.Cryptography
Imports System.Security.Cryptography.Xml
Imports System.Security.Cryptography.X509Certificates
Imports System.Text
Imports System.Xml
Imports System.Collections
Imports System.Reflection

Public Class RSAPKCS1SHA256SignatureDescription
    Inherits SignatureDescription

    Public Sub RSAPKCS1SHA256SignatureDescription()
        KeyAlgorithm = GetType(RSACryptoServiceProvider).FullName
        DigestAlgorithm = GetType(SHA256Managed).FullName   ' Note - SHA256CryptoServiceProvider is not registered with CryptoConfig
        FormatterAlgorithm = GetType(RSAPKCS1SignatureFormatter).FullName
        DeformatterAlgorithm = GetType(RSAPKCS1SignatureDeformatter).FullName
    End Sub

Wednesday, March 20, 2013

SQL'de herhangi bir tarih değerine ait Saat, Dakika ve Saniye bilgilerini almak

SQL'de herhangi bir tarih değerine ait Saat, Dakika ve Saniye bilgilerini almak

SELECT DATEPART(hh, GETDATE());
SELECT DATEPART(MI, GETDATE());
SELECT DATEPART(S, GETDATE());



Extracting hour, minute and second from a datetime value in SQL.

Sunday, February 24, 2013

App.Config dosyasında bulunan connectionStrings bölümünü şifrelemek.

App.Config dosyasında bulunan connectionStrings bölümünü şifrelemek.


<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=V10000-PC;Initial Catalog=SQLDB;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>


Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click

    Dim str() As String = Application.ExecutablePath.Split("\")
    Dim applicationName As String = str(str.Count - 1)
    applicationName = applicationName.Replace("EXE", "exe")
    Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(applicationName)



   If config.HasFile() Then
        EncryptAppConfig(config)
   End If
End Sub


Private Sub EncryptAppConfig(ByVal config As Configuration)
    Dim section As ConnectionStringsSection = config.GetSection("connectionStrings")
    If Not section.SectionInformation.IsProtected Then
       section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")
   End If
   config.Save(ConfigurationSaveMode.Modified)
   ConfigurationManager.RefreshSection("connectionStrings")
End Sub


Tuesday, January 22, 2013

VB.NET ToolStripDropDown Kullanımı

MyContent bir panel ya da herhangi bir kontrol elemanı olabilir.

Dim host As New ToolStripControlHost(MyContent)
host.Margin = Padding.Empty
host.Padding = Padding.Empty
host.AutoSize = False
host.Height = 180
host.Width = 490

Dim popup As New ToolStripDropDown()
popup.Margin = Padding.Empty
popup.Padding = Padding.Empty
popup.Size = host.Size
popup.BackColor = Color.White
popup.Items.Add(host)
popup.Show(pnlFill, btnSearch.Location.X, tlvMain.Height - 180)
Me.Controls.Remove(MyContent)

Tuesday, January 15, 2013

VB.NET'te Ayın son gününü bulmak.

VB.NET'te ayın son gününü en hızlı şekilde bulmak için, sanırım DateSerial fonksiyonu en ideal seçenek.

DateSerial(Year, Month + 1, 0)

Örnek:
Şubat 2013 tarihi için ayın son gününü bulmak : DateSerial(2013, 2 + 1, 0)

Wednesday, January 2, 2013

DataGridView'de istenen satıra odaklanmak.

Me.myDataGridView.CurrentCell = Me.myDataGridView.Rows(e.RowIndex).Cells(1)

ya da

Me.myDataGridView.Rows(e.RowIndex).Selected = True



VB.Net Combobox selectedvalue değeri System.Data.DataRowView döndürürse yapacağımız işlem?


Bazen bir combobox a ait selectedIndexChanged metodu altında selectedvalue değerine ulaşmak isteyebiliriz. Bu durumda selectedValue bize direk değer döndürmek yerine DataRowView olarak bir dönüş değeri verebilir. Böyle bir durumda ya aşağıdaki gibi direk metoddan çıkarız ya da selectedValue değerini DataRowView'e cast edip içeriğe ulaşabiliriz.

If TypeOf myComboBox.SelectedValue Is DataRowView Then
   Exit Sub
End If


ya da 

DirectCast(myComboBox.SelectedValue, DataRowView).Item(0)
DirectCast(myComboBox.SelectedValue, DataRowView).Item(1)

LinkWithin

Related Posts Plugin for WordPress, Blogger...