Saturday, March 21, 2009

Windows form close and open next form in Windows Application in C#.NET

Form2 Form2 = new Form2();


Form2.StartPosition = FormStartPosition.CenterParent;

this.Hide();

Form2.ShowDialog();

this.Close();

Wednesday, March 4, 2009

Find if a value exists in an Array in VB6.0

Module:

Option Explicit

Public Function IsInArray(FindValue As Variant, arrSearch As Variant) As Boolean
On Error GoTo LocalError
If Not IsArray(arrSearch) Then Exit Function
If Not IsNumeric(FindValue) Then FindValue = UCase(FindValue)
IsInArray = InStr(1, vbNullChar & Join(arrSearch, vbNullChar) & vbNullChar, _
vbNullChar & FindValue & vbNullChar) > 0
Exit Function
LocalError:
'Justin (just in case)
End Function

Usage:

Private Sub Command1_Click()
Dim x(5) As String

x(0) = 5
x(1) = 100
x(2) = 2000
x(3) = 11
x(4) = 7
x(5) = 1010
MsgBox IsInArray(10, x)
End Sub

Tuesday, March 3, 2009

VB code to show all table names of a databse

Dim rs As ADODB.Recordset
Dim con As New ADODB.Connection
Dim tables() As String
Dim table1, tablename As String
Dim i As Integer
Private Sub Command1_Click()
If con.State = adStateOpen Then
con.Close
End If
con.Open "Provider=SQLOLEDB.1;Data Source=.;Initial Catalog=GMS;Integrated Security=SSPI"
Set rs = New ADODB.Recordset
Set rs = con.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))

Do Until rs.EOF
'MsgBox rs!table_name
'Combo1.AddItem (rs!table_name)
If table1 = "" Then
table1 = rs!table_name
Else

table1 = table1 & "," & rs!table_name
End If


rs.MoveNext
Loop
rs.Close
tablename = "adcdata"
Set rs = Nothing
tables() = Split(table1, ",")
For i = 0 To UBound(tables()) - 1

If tablename = tables(i) Then
MsgBox "yes"
Else
End If

Next i

MsgBox table1
End Sub

Private Sub Form_Load()
'con.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & " data source=" & App.Path & "\rubberpark.mdb"
End Sub

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...