Using Stored Procedure Output parameter to return the GUID generated in the database.
(UniqueIdentifier has function NEWSEQUENTIALID() to generate a sequential GUID)
----------------
INSERT INTO myTable (columna) OUTPUT INSERTED.GUIDColumn VALUES(@columna)
----------------
INSERTED is a table created by Insert Trigger.
From:
http://blog.jemm.net/articles/databases/how-to-using-sql-server-2005s-output-to-return-generated-identity/
Friday, February 27, 2009
Wednesday, February 18, 2009
SVC and EndPoint
A *.svc file on the WCF host server has following declaration:
《 %@ ServiceHost Service="SilverService" Debug="true" % 》
Service "SilverService" is also defined in the web.config file "system.serviceModel"-"services" section. Usually it's a name extracted from a DLL class.
"SilverService" is the name of the service, and the service needs to define an EndPoint which has ABC(Address, Binding,Contract)
Contract points to the Interface of a service.
《 %@ ServiceHost Service="SilverService" Debug="true" % 》
Service "SilverService" is also defined in the web.config file "system.serviceModel"-"services" section. Usually it's a name extracted from a DLL class.
"SilverService" is the name of the service, and the service needs to define an EndPoint which has ABC(Address, Binding,Contract)
Contract points to the Interface of a service.
Call WCF Service Operations Asynchronously
Private nor As SilverService.SilverServiceClient = Nothing
Options 1: Begin/End event
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim pat As New PageAsyncTask(AddressOf BeginGetDataAsync, AddressOf EndGetDataAsync, Nothing, Nothing)
Page.RegisterAsyncTask(pat)
End Sub
Private Function BeginGetDataAsync(ByVal sender As Object, ByVal e As EventArgs, ByVal acb As AsyncCallback, ByVal extraData As Object) As IAsyncResult
nor = New SilverService.SilverServiceClient()
Return nor.BeginGetData("Limin", acb, extraData)
End Function
Private Sub EndGetDataAsync(ByVal ar As IAsyncResult)
lblInfo.Text = nor.EndGetData(ar)
End Sub
Option 2: Completed Event
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
nor = New SilverService.SilverServiceClient()
AddHandler nor.GetDataCompleted, AddressOf Client_GetDataCompleted
nor.GetDataAsync("Limin")
End Sub
Private Sub Client_GetDataCompleted(ByVal sender As Object, ByVal e As SilverService.GetDataCompletedEventArgs)
lblInfo.Text = e.Result.ToString
nor = Nothing
End Sub
Options 1: Begin/End event
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim pat As New PageAsyncTask(AddressOf BeginGetDataAsync, AddressOf EndGetDataAsync, Nothing, Nothing)
Page.RegisterAsyncTask(pat)
End Sub
Private Function BeginGetDataAsync(ByVal sender As Object, ByVal e As EventArgs, ByVal acb As AsyncCallback, ByVal extraData As Object) As IAsyncResult
nor = New SilverService.SilverServiceClient()
Return nor.BeginGetData("Limin", acb, extraData)
End Function
Private Sub EndGetDataAsync(ByVal ar As IAsyncResult)
lblInfo.Text = nor.EndGetData(ar)
End Sub
Option 2: Completed Event
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
nor = New SilverService.SilverServiceClient()
AddHandler nor.GetDataCompleted, AddressOf Client_GetDataCompleted
nor.GetDataAsync("Limin")
End Sub
Private Sub Client_GetDataCompleted(ByVal sender As Object, ByVal e As SilverService.GetDataCompletedEventArgs)
lblInfo.Text = e.Result.ToString
nor = Nothing
End Sub
Tuesday, February 17, 2009
WCF ASP.NET compatibility
web.config
serviceHostingEnvironment aspNetCompatibilityEnabled="true"
Class attribute decoration
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ClassName
.
.
.
End Class
serviceHostingEnvironment aspNetCompatibilityEnabled="true"
Class attribute decoration
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ClassName
.
.
.
End Class
Monday, February 16, 2009
Sudoku Generate
Do While count < 81
count = 0
For i As Integer = 0 To 8
For j As Integer = 0 To 8
xy(i, j) = 0
Next
Next
For i As Integer = 1 To 9 ' Number loop
For index As Integer = 1 To 9
x(index) = False
y(index) = False
Next
For j As Integer = 1 To 3 'Block loop
For k As Integer = 1 To 3 'Block loop
lx = (j - 1) * 3 + rd.Next(1, 3)
ly = (k - 1) * 3 + rd.Next(1, 3)
Do While Not (xy(lx - 1, ly - 1) = 0 And x(lx) = False And y(ly) = False)
For j1 As Integer = 3 To 1 Step -1
For k1 As Integer = 3 To 1 Step -1
lx = j1 + +(j - 1) * 3
ly = k1 + (k - 1) * 3
If (xy(lx - 1, ly - 1) = 0 And x(lx) = False And y(ly) = False) Then
Exit Do
End If
Next
Next
i = 10
k = 4
j = 4
Exit Do
Loop
'Find it, set value
If xy(lx - 1, ly - 1) = 0 And x(lx) = False And y(ly) = False Then
xy(lx - 1, ly - 1) = i
x(lx) = True
y(ly) = True
count = count + 1
End If
Next
Next
Next
Loop
count = 0
For i As Integer = 0 To 8
For j As Integer = 0 To 8
xy(i, j) = 0
Next
Next
For i As Integer = 1 To 9 ' Number loop
For index As Integer = 1 To 9
x(index) = False
y(index) = False
Next
For j As Integer = 1 To 3 'Block loop
For k As Integer = 1 To 3 'Block loop
lx = (j - 1) * 3 + rd.Next(1, 3)
ly = (k - 1) * 3 + rd.Next(1, 3)
Do While Not (xy(lx - 1, ly - 1) = 0 And x(lx) = False And y(ly) = False)
For j1 As Integer = 3 To 1 Step -1
For k1 As Integer = 3 To 1 Step -1
lx = j1 + +(j - 1) * 3
ly = k1 + (k - 1) * 3
If (xy(lx - 1, ly - 1) = 0 And x(lx) = False And y(ly) = False) Then
Exit Do
End If
Next
Next
i = 10
k = 4
j = 4
Exit Do
Loop
'Find it, set value
If xy(lx - 1, ly - 1) = 0 And x(lx) = False And y(ly) = False Then
xy(lx - 1, ly - 1) = i
x(lx) = True
y(ly) = True
count = count + 1
End If
Next
Next
Next
Loop
Subscribe to:
Posts (Atom)
Blog Archive
- June (1)
- April (2)
- April (1)
- August (1)
- April (1)
- March (1)
- February (1)
- March (1)
- February (2)
- August (1)
- April (1)
- March (1)
- February (2)
- November (3)
- September (1)
- August (1)
- June (1)
- April (1)
- March (1)
- February (5)
- January (1)
- August (1)
- July (1)
- January (2)
- August (1)
- June (1)
- March (4)
- February (3)
- January (3)