Google Mobile Ads

Friday, May 24, 2013

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

LinkWithin

Related Posts Plugin for WordPress, Blogger...