Entries by admin

VSTO WEBBROWSER

Imports Microsoft.Office.Tools.Ribbon Imports System.Data.SqlClient Public Class MENU DELAY MODULE Private Sub MENU_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click ‘Excel Defination Dim NativeWorksheet As Microsoft.Office.Interop.Excel.Worksheet = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet Dim Excel_Range As Excel.Range ‘Data Source Dim SQLCon As New SqlConnection With {.ConnectionString = […]

EXCEL GET FROM SQL AND SUBMIT TO SQL

Imports Microsoft.Office.Tools.Ribbon Imports System.Data.SqlClient Public Class MENU Private Sub MENU_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click ‘Excel Defination Dim NativeWorksheet As Microsoft.Office.Interop.Excel.Worksheet = Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet Dim Excel_Range As Excel.Range ‘Data Source Dim SQLCon As New SqlConnection With {.ConnectionString = “Server=foxtube.com.au;Database=e2s;User=sa;Pwd=xxxxxxxx;”} Dim […]

VBA CONNECT SQL SERVER

Sub GetDataFromADO() Dim Cn As ADODB.Connection Dim Server_Name As String Dim Database_Name As String Dim User_ID As String Dim Password As String Dim SQLStr As String Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset Server_Name = “foxtube.com.au” ‘ Enter your server name here Database_Name = “SQLTEST” ‘ Enter your database name here User_ID = […]

DLL SAMPLE

Public Class test1 Public Function test(ByVal a As Long, ByVal b As Long) As Long Return a + b End Function End Class Imports ClassLibrary1 Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Show() Dim localtest As New ClassLibrary1.test1 MsgBox(localtest.test(2, 5)) End Sub End Class

TCP SOCKETS SERVER

Imports System.Net Imports System.IO Imports System.Net.Sockets Public Class Form1 Dim Listning As TcpListener Dim Allclient As TcpClient Dim clientList As New List(Of ClassforClient) Dim pReader As StreamReader Dim pClient As ClassforClient Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Listning = New TcpListener(IPAddress.Any, 3818) Listning.Start() UpdateList(“Server Starting”, False) Listning.BeginAcceptTcpClient(New AsyncCallback(AddressOf AcceptClient), Listning) End […]

TCP SOCKETS CLIENT

Imports System.Net Imports System.IO Imports System.Net.Sockets Public Class Form1 Dim client As TcpClient Dim sWriter As StreamWriter Dim NIckFrefix As Integer = New Random().Next(1111, 9999) Sub xLoad() Handles Me.Load Me.Text &= ” ” & NIckFrefix End Sub Delegate Sub _xUpdate(ByVal str As String) Sub xUpdate(ByVal str As String) If InvokeRequired Then Invoke(New _xUpdate(AddressOf xUpdate), str) […]

SAVE&CLICK

Public Class Form1 Private Declare Auto Function FindWindowEx Lib “user32” (ByVal parentHandle As Integer, _ ByVal childAfter As Integer, _ ByVal lclassName As String, _ ByVal windowTitle As String) As Integer Private Declare Function SetForegroundWindow Lib “user32” (ByVal hwnd As IntPtr) As Long Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim handle […]

EXCEL TO SQL(server)

Imports System.Data.SqlClient ‘Imports System.Data.Sql ‘Imports System.Data.OleDb Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Show() ‘Read From Excel Dim connectionString As String ‘ Used to store the connection string Dim customerList As New DataSet ‘ Used to store the temp records readed from the Excel file Dim excelData As OleDb.OleDbDataAdapter […]

EXCEL TO ACCESS

Imports System.Data.OleDb Imports System.Data.SqlClient Imports System.Data.Sql Imports System.Data Public Class Form1 Dim ds1 As New DataSet Dim ds2 As New DataSet Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim connectionString As String ‘ Used to store the connection string Dim customerList As New DataSet ‘ Used to store the temp records readed […]

EXCEL TO SQL SERVER

Imports System.Data.SqlClient ‘Imports System.Data.Sql ‘Imports System.Data.OleDb Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Show() ‘Read From Excel Dim connectionString As String ‘ Used to store the connection string Dim customerList As New DataSet ‘ Used to store the temp records readed from the Excel file Dim excelData As OleDb.OleDbDataAdapter […]

SQL SIMPLE CONNECTION

Me.Show() Dim SQLCon As New SqlConnection With {.ConnectionString = “Server=192.168.1.101;Database=database_alan;User=sa;Pwd=yXXXXXXX;”} Dim sqltxt As String = “select * from User_Info” ‘定义sql语句 Dim sqlcmd As New SqlCommand(sqltxt, SQLCon) ‘定义sqlCommand Dim userReader As SqlDataReader ‘定义sqldatareader Try SQLCon.Open() ‘打开连接 userReader = sqlcmd.ExecuteReader ‘生成sqldatareader userReader.Read() ‘读取数据 MsgBox(userReader.Item(3)) ‘显示读取的第四个数据 userReader.Close() ‘关闭阅读 Catch ex As Exception MsgBox(ex.Message) Finally sqlcmd.Dispose() ‘ 释放sqlCommand End […]

SQL FIREWALL

在运行SQL Server的服务器上,我们要找到哪些是SQL Server 正在侦听的端口,并将其添加到Windows防火墙的入站例外。 首先,我们需要添加 SQL Server 服务侦听 Windows 防火墙的入站例外,以便客户端可以通过 Windows 防火墙建立 SQL Server 连接的 TCP 端口。 其次,如果我们不在连接字符串中指定 TCP 端口,SQL Server 不侦听 TCP 1433 端口,我们就需要添加SQL Server Brower Services侦听的UDP 1434 端口到 Windows 防火墙的入站例外。 如何找到SQL Server正在侦听的TCP端口,可以按一下步骤: 1. 打开 SQL Server 配置管理器中,从开始->所有程序-> Microsoft SQL Server 2005/2008/2008 R2 ->配置工具 ; 2. 在SQL Server 配置管理器窗口 , 左面板中的SQL 服务器网络配置节点下单击协议的 双击TCP/IP在右面板中,切换到IP 地址选项卡,可以找出所有 […]