[MSSQL数据库SA权限分配反正入侵]大家都知道MSSQL中SA权限是什么,可以说是至高无上。今天我就它的危害再谈点儿,我所讲的是配合NBSI上传功能得到WebShell。在讲之前先说几个条件,否则得到Shell是有难度的。1.存...+阅读
Public rsNew As ADODB.Recordset Public CnNew As ADODB.Connection Public addFlag As Boolean '连接数据库 Public Function OpenCn() As Boolean Dim Mag As String On Error GoTo strErrMag Set CnNew = New ADODB.Connection CnNew.ConnectionTimeout = 25 CnNew.Provider = "sqloledb" CnNew.Properties("data source").value = "" 'SQL服务器的名 CnNew.Properties("initial catalog").value = "pubs"'库名 CnNew.Properties("integrated security").value = "SSPI"'登陆类型 'con.Properties("user id").value = "sa" 'con.Properties("password").value = "w" CnNew.Open OpenCn = True addFlag = True Exit Function strErrMag: Mag = "数据库末连接" Call MsgBox(Mag, vbOKCancel, "错误:数据库连接") addFlag = False End End Function Public Sub Clocn() '闭关数据库 On Error Resume Next If CnNew.State <> adStateClosed Then CnNew.Close Set CnNew = Nothing End Sub Public Function OpenRs(ByVal strSql As String) As Boolean '连接数据库记录集 Dim Mag As String Dim rpy As Boolean On Error GoTo strErrMag Set rsNew = New ADODB.Recordset If addFlag = False Then rpy = OpenCn With rsNew .ActiveConnection = CnNew .CursorLocation = adUseClient .CursorType = adOpenKeyset .LockType = adLockOptimistic .Open strSql End With addFlag = True OpenRs = True Exit Function strErrMag: Mag = "数据库数据集末连接" Call MsgBox(Mag, vbOKOnly, "错误:数据库连接") OpenRs = False End End Function Public Sub cloRs() '闭关数据集 On Error Resume Next If rsNew.State <> adStateClosed Then rsNew.Close Set rsNew = Nothing End Sub
VB连接远程数据库
ACCESS数据库不可以的!!
您可以用Sql server数据库....这个就可以远程访问。。
'Sql server数据库连接方式
Dim ServerIP As String, UserName As String, Password As String, DataName As String ServerIP = "127.0.0.1" 'IP UserName = "Linlin" '用户名 Password = "pass" '密码 DataName = "Linlin" '数据库名 conn.ConnectionString = "Driver={SQL Server}; Database=" & UserName & "; UID=" & UserName & "; PWD=" & Password & "; Server=" & ServerIP conn.Open
vb如何连接上远程SQL数据库
不知道你为什么要用ADOC来配置...直接用VB代码就OK了。
公共模块:
Private Function Selectsql(SQL As String) As ADODB.Recordset '返回ADODB.Recordset对象
Dim ConnStr As String
Dim Conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set Conn = New ADODB.Connection
'On Error GoTo MyErr:
ConnStr = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=登录数据库用户名(默认为sa);Password=登录数据库密码;Initial Catalog=数据库名;Data Source=服务器名(IP地址)" '这是连接SQL数据库的语句
Conn.Open ConnStr
rs.CursorLocation = adUseClient
rs.Open Trim$(SQL), Conn, adOpenDynamic, adLockOptimistic
End Function
调用:
SQL = "SELECT * FROM 用户表 WHERE 用户名='" & Combo1.Text & "' AND 密码='" & Text1.Text & "' "
Set rs = Selectsql(SQL)
vb数据库操作
VB.net 操作Access数据库的一些常用方法,代码如下 Imports System Imports System.Data.SqlClient Imports System.Configuration Imports System.Collections.Generic Imports System.Text Imports System.Data Imports System.Configuration.ConfigurationSettings Imports System.Data.OleDb Public Class DB Private Shared com As OleDb.OleDbCommand Private Shared reader As OleDb.OleDbDataReader Private Shared adapter As OleDb.OleDbDataAdapter Private Shared conn As OleDb.OleDbConnection '''''' 获取数据库连接 ''''''''''''Public Shared ReadOnly Property NewConn() As OleDbConnection Get Dim connectionString As String 'connectionString = System.Configuration.ConfigurationSettings.GetConfig("Supermarket") '连接2010数据库 'connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\GCU.accdb" '连接03-07数据库 connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\JL\GCU.MDB" '应该在这里先判断conn是否为Nothing If conn Is Nothing Then conn = New OleDb.OleDbConnection(connectionString) End If If conn.StateConnectionState.Open Then conn.Open() End If Return conn End Get End Property '''''' 执行增删改(无参) ''''''执行的Sql语句''''''Public Shared Function ExecuteNonQuery(ByVal sql As String) As Integer com = New OleDb.OleDbCommand(sql, NewConn()) Return com.ExecuteNonQuery() End Function '''''' 执行增删改(有参) '''''''''''''''Public Shared Function ExecuteNonQuery(ByVal sql As String, ByVal para As OleDbParameter()) As Integer com = New OleDb.OleDbCommand(sql, NewConn) com.Parameters.AddRange(para) Return com.ExecuteNonQuery() End Function '''''' 执行增删改的存储过程 '''''''''''''''Public Shared Function ExecuteNonQuery(ByVal para As SqlParameter(), ByVal ProcedureName As String) As Integer Dim cmd As OleDb.OleDbCommand cmd = New OleDb.OleDbCommand() cmd.Connection = NewConn() cmd.CommandText = ProcedureName cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.AddRange(para) Return com.ExecuteNonQuery End Function '''''' 执行查询(返回一个结果集,无参) ''''''''''''Public Shared Function GetScalar(ByVal sql As String) As String Dim dataset As DataSet dataset = New DataSet() com = New OleDb.OleDbCommand(sql, NewConn) adapter = New OleDbDataAdapter(com) adapter.Fill(dataset) If dataset.Tables.Count >0 And dataset.Tables(0).Rows.Count >0 Then Return dataset.Tables(0).Rows(0)(0).ToString() End If Return "Null" End Function '''''' 执行查询(返回一个结果集,有参) '''''''''''''''Public Shared Function GetScalar(ByVal sql As String, ByVal para As SqlParameter()) As Integer com = New OleDb.OleDbCommand(sql, NewConn) com.Parameters.AddRange(para) Return Convert.ToInt32(com.ExecuteScalar()) End Function '''''' 执行查询(返回一行数据,无参) ''''''''''''Public Shared Function GetReader(ByVal sql As String) As OleDbDataReader com = New OleDb.OleDbCommand(sql, NewConn) reader = com.ExecuteReader() Return reader End Function '''''' 执行查询(返回一行数据,有参) '''''''''''''''Public Shared Function GetReader(ByVal sql As String, ByVal para As SqlParameter()) As OleDbDataReader com = New OleDb.OleDbCommand(sql, NewConn) com.Parameters.AddRange(para) reader = com.ExecuteReader() Return reader End Function '''''' 执行查询(返回一个数据集,无参) ''''''''''''Public Shared Function GetDataSet(ByVal sql As String) As DataTable Dim dataset As ...
以下为关联文档:
VB6.0使用ADO对象连接数据库1. 定义连接对象 Global DBconnect As New ADODB.Connection 2. 执行连接语句 If DBconnect.State = adStateOpen And Not IsEmpty(adStateOpen) Then DBconnect.Close 连接OD...
VB怎么实现访问远程access数据库这是网络编程 远程要有客户端(或服务端)程序的,如果没有远程程序作支持,一般会被对方防火墙、安全策略、服务等设置情况阻挡(除非对方是特定服务器计算机)。 访问远程access数据库...
你好!请问vb6 0中怎样远程访问access数据库在工程里引用microsoft activex data objects 2.7 library Dim cn As New ADODB.Connection, rs1 As New ADODB.Recordset, sql As String '在通用声明里定义,其中cn是连接对...
初学VB请教VB60连接SQL数据库具体步骤Dim conn As New ADODB.Connection Dim rs(10) As New ADODB.Recordset db = App.Path & "\db\data.mdb" conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Pa...
如何用DB2客户端连接远程数据库在DB2客户机上连接远程DB2服务之前,必须正确设置服务端通信协议。DB2支持的协议有TCP/IP、NetBIOS、NPIPE等。 连接远程DB2数据库服务的基本步骤如下: 1. 在客户机上对远程DB2...
如何远程连接db2数据库如果要理解编目,我先简单讲一下DB2数据库的体系结构,在DB2数据库中最大的概念是系统(节点)也就是主机,下面是实例,实例下面是数据库,然后是表空间,然后是数据库对象。现在假设你有一...
数据库教程 sql怎样外网连接远程数据库要点: 1.确认服务器端SQL服务端口号是否为:1433 2.如果不是1433,配置客户端 3.建立服务器端登录帐号,确保角色及管理数据库 一、查看服务器端情况 1. 看ping 服务器IP能否ping通...
vb连接access数据库代码详解请用MICROSOFT jet 4.0 OLE DB Provider引擎连接ACCESS数据库,方法如下: 新建工程时选数据工程,此时VB6集成调试环境左边工具箱内已加载了有关数据库编程必须的控件。 然后在FO...
vb连接access数据库代码详细解释第一步:建立一个标准EXE工程,并且在菜单--工程加添一个类模块和一个计时器(DataEnvironment1,可以在部件--设计器里找到) 第二步:在工程----引用----找到microsoft activex date o...