大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
1、首先打开Visual Studio 2008代码窗口,添加引用。
目前成都创新互联已为超过千家的企业提供了网站建设、域名、虚拟空间、成都网站托管、企业网站设计、滨城网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
2、输入以下代码:Public conn1 As SqlConnection = New SqlConnection 。
3、声明关键字 Public;(因为是全局变量,所以用Public 来声明)。
4、如果SQL 数据库就在本机,则用以下代码连接。
5、如果代码太长,影响可读性,可以用空格加"_"后,回车换行即可。
Private Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) Handles Button Click 备份数据库 BACKUP DATABASE Test TO DISK= C:\Backup WITH Format Dim cn As SqlConnection Dim cm As SqlCommand cn = getDB() cm = New SqlCommand( BACKUP DATABASE JXbase TO DISK= C:\Backup WITH Format cn) cn Open() cm ExecuteNonQuery() MsgBox( 备份成功 ) cn Close()
End Sub
恢复 Private Sub Button _Click(ByVal sender As System Object ByVal e As System EventArgs) Handles Button Click Dim cn As New SqlConnection Dim cn As New SqlConnection Dim mydr As SqlDataReader Dim str As String
Dim tmpConnectionString As String = Data Source=JJK;Initial Catalog=master;Integrated Security=True cn ConnectionString = tmpConnectionString cn ConnectionString = tmpConnectionString cn Open() cn Open() Dim cm As SqlCommand = New SqlCommand( select spid from master sysprocesses where dbid=db_id( JXbase ) cn) mydr = cm ExecuteReader()
Dim cm As SqlCommand = New SqlCommand() cm Connection = cn
While (mydr Read()) 杀死进程
str = kill mydr( spid ) ToString() cm CommandText = str cm CommandType = CommandType Text Application DoEvents() cm ExecuteNonQuery() 杀进程 End While mydr Close() cm = New SqlCommand( RESTORE DATABASE JXbase FROM DISK= C:\Backup cn) 恢复备份 cm ExecuteNonQuery() MsgBox( 恢复成功成功 ) cn Close() cn Close()
lishixinzhi/Article/program/net/201311/12901
很慢。根据查询vbnet相关资料得知,vbnet更新sql数据库速度是很慢的。vbnet的sql语句能查询到库中的数据,但是速度是相当的慢。