本文介绍了Dataadapter.update抛出错误;数据表localdb中的datacollumn rwuser for sourcecollumn rwuser不会被激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 亲爱的, 我正在尝试用多个表更新数据集。但是,我想要更新时间,我要更新的第一个表会抛出一个错误,该列不会在该表中出现错误。这确实是通过,但是在我想要更新的最后一个表中只有列表。我确实尝试交换(放在最后一个和所有)但仍然是继续给我相同的错误与相同的collumn名称。 总是缺少collumn rwUser ..除了里面有rwUser的表格,这将正确完成。 我的代码下面有我以及我所有的表格和行。 我使用Access 2016创建的数据库,是一个aacdb。我正在使用Visual Basic 2017 数据库; 以tb开头的单词是Tables。Dear all,I am trying to update a dataset with multiple tables. However evertime I want to update, the first table that I want to update throws an error, that collumn doesn't excist in that table. This is indeed thru, but the collumn only excist in the last table I want to update. I did try to swap (put last first and all) but still it is keep giving me the same error with the same collumn name.Always it is missing collumn rwUser..except in the table with the rwUser inside this will be done correctly.Below my code I have and also all the tables and rows I have.The Database I created with Access 2016 and is an aacdb. And I am using Visual Basic 2017The Database;Words starting with tb are the Tables.The Tables / rows I have;•tbAuthorizationsoAuthorizationIDorwAuthorization (this to be used as sourch for table tbUsersAuthorizations / rwSetUser, rwSetData, rwSetSettings, rwSetReports•tbLocalDataFolderoLocalDataBaseIDorwDatabaseorwLocation•tbServerDataFolderoServerDatabaseIDorwDatabaseorwLocation•tbUserAuthorizationsoUserAuthorizationIDorwAuthUser = Lookup / relation of tbUsers – rwUserIDorwSetUser = Lookup / relation of tbAuthorizations - AuthorizationIDorwSetData = Lookup / relation of tbAuthorizations - AuthorizationIDorwIncludeFixDataorwSetSettings = Lookup / relation of tbAuthorizations - AuthorizationIDorwSetReports = Lookup / relation of tbAuthorizations – AuthorizationID•tbUsersoUserIDorwUser (this to be used as sourch for table tbUsersAuthorizations – rwUser)orwInlogNameorwPasswordorwSercretQuestionorwSecretAnswerorwEmailorwComputerNameorwWindowsUserorwPasswordLoginorwHoldOnStartorwRememberNameorwRememberPassword 我的尝试:What I have tried:Public Class Form1 Dim con As New OleDb.OleDbConnection Dim dbProvider As String Dim dbSource As String Dim dbFolder As String Dim dbName As String Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load dbProvider = "PROVIDER=MICROSOFT.ACE.OLEDB.12.0;" dbName = "D:\SystemSettings.accdb" dbSource = "DATA SOURCE = " & dbName con.ConnectionString = dbProvider & dbSource con.Open() da = New OleDb.OleDbDataAdapter("SELECT * FROM tbAuthorizations", con) da.Fill(ds, "AuthDB") da.SelectCommand.CommandText = "SELECT * FROM tbLocalDataFolder" da.Fill(ds, "LocalDB") da.SelectCommand.CommandText = "SELECT * FROM tbServerDataFolder" da.Fill(ds, "ServerDB") da.SelectCommand.CommandText = "SELECT * FROM tbUserAuthorizations" da.Fill(ds, "UserAuthDB") da.SelectCommand.CommandText = "SELECT * FROM tbUsers" da.Fill(ds, "UsersDB") con.Close() End Sub Private Sub BtnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click Dim cb As New OleDb.OleDbCommandBuilder(da) Dim dsNewRow As DataRow Try dsNewRow = ds.Tables("UsersDB").NewRow() dsNewRow.Item("rwUser") = txtNaam.Text dsNewRow.Item("rwInlogName") = TxtGeboorteplaats.Text ds.Tables("UsersDB").Rows.Add(dsNewRow) da.Update(ds, "UsersDB") dsNewRow = ds.Tables("LocalDB").NewRow() dsNewRow.Item("rwDatabase") = txtNaam.Text dsNewRow.Item("rwLocation") = TxtGeboorteplaats.Text ds.Tables("LocalDB").Rows.Add(dsNewRow) da.Update(ds, "LocalDB") ''exception error; DataCollumn rwUser in DataTable LocalDB for SourceCollumn rwUser doesn't excist dsNewRow = ds.Tables("ServerDB").NewRow() dsNewRow.Item("rwDatabase") = txtNaam.Text dsNewRow.Item("rwLocation") = TxtGeboorteplaats.Text ds.Tables("ServerDB").Rows.Add(dsNewRow) da.Update(ds, "ServerDB") ''exception error; DataCollumn rwUser in DataTable ServerDB for SourceCollumn rwUser doesn't excist dsNewRow = ds.Tables("UserAuthDB").NewRow() dsNewRow.Item("rwAuthUser") = txtNaam.Text dsNewRow.Item("rwSetUser") = TxtGeboorteplaats.Text ds.Tables("UserAuthDB").Rows.Add(dsNewRow) da.Update(ds, "UserAuthDB") ''exception error; DataCollumn rwUser in DataTable UserAuthDB for SourceCollumn rwUser doesn't excist Catch ex As Exception Dim s As String s = ex.StackTrace End Try End SubEnd Class推荐答案Private Sub BtnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click Dim cb As New OleDb.OleDbCommandBuilder(da) Dim dsNewRow As DataRow Dim query As String Dim i As Integer Try dsNewRow = ds.Tables("UsersDB").NewRow() dsNewRow.Item("rwUser") = txtNaam.Text dsNewRow.Item("rwInlogName") = TxtGeboorteplaats.Text ds.Tables("UsersDB").Rows.Add(dsNewRow) query = "INSERT INTO tbLocalDataFolder (rwDatabase,rwLocation) VALUES ('" & txtNaam.Text & "','" & TxtGeboorteplaats.Text & "')" executquery(query, con) dsNewRow.Item("rwDatabase") = txtNaam.Text dsNewRow.Item("rwLocation") = TxtGeboorteplaats.Text ds.Tables("LocalDB").Rows.Add(dsNewRow) query = "INSERT INTO tbLocalDataFolder (rwDatabase,rwLocation) VALUES ('" & txtNaam.Text & "','" & TxtGeboorteplaats.Text & "')" executquery(query, con) Catch ex As Exception Dim s As String s = ex.StackTrace End TryEnd SubPublic Sub executquery(query As String, connec As OleDb.OleDbConnection) Dim commandOleDb As New OleDb.OleDbCommand(query, connec) con.Open() commandOleDb.ExecuteNonQuery() con.Close()End Sub 这篇关于Dataadapter.update抛出错误;数据表localdb中的datacollumn rwuser for sourcecollumn rwuser不会被激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 19:52