declare @go_qty int
set @go_qty=1
while (@go_qty<=2)
begin
print @go_qty
set @go_qty+=1
end
declare @go_qty int
set @go_qty=1
while (@go_qty<=2)
begin
print @go_qty
set @go_qty+=1
end
--
windows 11 基於安全性考量,使用者帳號已被封鎖
使用Windows 鍵+ R 開啟執行視窗,並輸入gpedit.msc。 依序點開,
電腦設定=>Windows 設定=>安全性設定=>帳戶原則=>帳戶鎖定原則,並點擊『帳戶鎖定閾值』。 將設定值調整為0 即可。
--
Imports System.Diagnostics
Imports System.Net.Sockets
Imports System.Threading
Public Class Form4
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ip = "192.168.1.10" 'SQL Server主機的IP位址。
Dim port = 1433 'SQL Server的port預設是1433。
Dim sw As Stopwatch = New Stopwatch()
sw.Start()
Dim isConnection = TestConn(ip, port)
sw.[Stop]()
Dim message = String.Empty
If isConnection Then
message = "連線成功。 經過{0}秒。"
Else
message = "連線失敗了! 經過{0}秒!"
End If
Dim t = sw.ElapsedMilliseconds / 1000.0
MessageBox.Show(String.Format(message, t))
End Sub
Public Function TestConn(ip As String, port As Integer) As Boolean
Try
Using tc As TcpClient = New TcpClient()
Dim result As IAsyncResult = tc.BeginConnect(ip, port, Nothing, Nothing)
Dim start = Date.Now
Do
SpinWait.SpinUntil(Function() False, 100)
If result.IsCompleted Then Exit Do
Loop While Date.Now.Subtract(start).TotalSeconds < 0.3
If result.IsCompleted Then
tc.EndConnect(result)
Return True
End If
tc.Close()
If Not result.IsCompleted Then
Return False
End If
End Using
Catch ex As Exception
Console.WriteLine(ex.Message)
Throw
End Try
Return False
End Function
End Class
參考引用:SqlConnection.ConnectionTimeout
---
private static void OpenSqlConnection()
{
string connectionString = GetConnectionString();
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
Console.WriteLine("State: {0}", connection.State);
Console.WriteLine("ConnectionTimeout: {0}",
connection.ConnectionTimeout);
}
}
static private string GetConnectionString()
{
// To avoid storing the connection string in your code,
// you can retrieve it from a configuration file, using the
// System.Configuration.ConfigurationSettings.AppSettings property
return "Data Source=(local);Initial Catalog=AdventureWorks;"
+ "Integrated Security=SSPI;Connection Timeout=30";
}
win7 x64 C# 讀取 delphi Paradox db
Paradox 4 database connect and edit inside c#
##
C# Application to import paradox data to SQL Server
----------------
C# code:
var strPath = @"D:\Test\4#新程序全兼容\4#新程序全兼容\Data";
string myConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPath + ";Extended Properties=Paradox 5.x;";
string mySelectQuery = "select * from TD2002002;";
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
myConnection.Open();
OleDbDataAdapter da = new OleDbDataAdapter(mySelectQuery, myConnection);
DataSet ds = new DataSet();
da.Fill(ds);
----------
VB code:
Dim strPath As Object = "D:\Test\4#新程序全兼容\4#新程序全兼容\Data"
Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPath + ";Extended Properties=Paradox 5.x;"
Dim mySelectQuery As String = "select * from TD2002002;"
Dim myConnection As New OleDbConnection(myConnectionString)
myConnection.Open()
Dim da As New OleDbDataAdapter(mySelectQuery, myConnection)
Dim ds As New DataSet()
da.Fill(ds)