vb.net 在访问数据库中重命名 table
vb.net Rename table in access database
我正在制作一个应用程序,我想在其中重命名访问数据库 table。我使用 OLEDBConnection 连接到数据库,并选择 table 和 textbox.Text,这是我在注册时创建的。在另一种形式中,我应该更改用户名,但是当我这样做时,我的 select table 系统会崩溃。
所以问题是如何在访问数据库中重命名 table?
(看了一些教程,但是microsoft MSDN对我来说不是很清楚)
这是我用来重命名用户名的代码:
pro = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = Z:\Password manager\Password
Database\Database.accdb"
connstring = pro
myconn.ConnectionString = connstring
Dim cmd As OleDbCommand = New OleDbCommand("UPDATE LogIN SET [Meno]='" & txtName.Text &
"',[Heslo]='" & EncryptText(txtPass.Text) & "',[E-mail]='" & txtMail.Text & "' WHERE
Meno= '" & txtName.Text & "'", myconn)
If myconn.State = ConnectionState.Closed Then myconn.Open()
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
MsgBox("Your name was changed")
Catch ex As Exception
MsgBox("Error")
End Try
myconn.Close()
My.Settings.LogINSetting = txtName.Text
My.Settings.Save()
您可以使用 ADOX to do so. In your Project, add a Reference to Microsoft ADO Ext. 6.0 for DDL and Security (it's under COM) and use the Catalog Object:
Dim ADOXCatalog As New ADOX.Catalog
ADOXCatalog.ActiveConnection = myconn
ADOXCatalog.Tables("CurrentTableName").Name = "NewTableName"
我正在制作一个应用程序,我想在其中重命名访问数据库 table。我使用 OLEDBConnection 连接到数据库,并选择 table 和 textbox.Text,这是我在注册时创建的。在另一种形式中,我应该更改用户名,但是当我这样做时,我的 select table 系统会崩溃。
所以问题是如何在访问数据库中重命名 table?
(看了一些教程,但是microsoft MSDN对我来说不是很清楚)
这是我用来重命名用户名的代码:
pro = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = Z:\Password manager\Password
Database\Database.accdb"
connstring = pro
myconn.ConnectionString = connstring
Dim cmd As OleDbCommand = New OleDbCommand("UPDATE LogIN SET [Meno]='" & txtName.Text &
"',[Heslo]='" & EncryptText(txtPass.Text) & "',[E-mail]='" & txtMail.Text & "' WHERE
Meno= '" & txtName.Text & "'", myconn)
If myconn.State = ConnectionState.Closed Then myconn.Open()
Try
cmd.ExecuteNonQuery()
cmd.Dispose()
MsgBox("Your name was changed")
Catch ex As Exception
MsgBox("Error")
End Try
myconn.Close()
My.Settings.LogINSetting = txtName.Text
My.Settings.Save()
您可以使用 ADOX to do so. In your Project, add a Reference to Microsoft ADO Ext. 6.0 for DDL and Security (it's under COM) and use the Catalog Object:
Dim ADOXCatalog As New ADOX.Catalog
ADOXCatalog.ActiveConnection = myconn
ADOXCatalog.Tables("CurrentTableName").Name = "NewTableName"