I'm trying to add a column into a dataset and copy a part of an other datarow into the new made column like this:
VB Code:
Dim DsTemp As DataSet Dim myConnection As Odbc.OdbcConnection Dim ConnectieString As String Dim myDataRowsCommandBuilder As Odbc.OdbcCommandBuilder myConnection = New Odbc.OdbcConnection(GetDatabaseConn) 'get's the connectionstring from an other public place ConnectieString = "SELECT * FROM Humans" mySqlDataAdapter = New Odbc.OdbcDataAdapter(ConnectieString, myConnection) DsTemp = New DataSet myDataRowsCommandBuilder = New Odbc.OdbcCommandBuilder(mySqlDataAdapter) mySqlDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey mySqlDataAdapter.Fill(DsTemp, "Humans") myConnection.Close() Dim Drow As DataRow If DsTemp.Tables(0).Columns("Activity") Is Nothing Then Dim DC As DataColumn = New DataColumn("Activity") DC.DataType = System.Type.GetType("System.Int32") DsTemp.Tables(0).Columns.Add(DC) End If For Each Drow In DsTemp.Tables(0).Rows If Len(Drow!projectnr) > 10 Then Drow!Activity = Val(Mid(Drow!Projectnr, 12)) Drow!Projectnr = Mid(Drow!Projectnr, 1, 10) End If Next Try mySqlDataAdapter.Update(DsTemp, "Humans") Catch ex As Exception MsgBox(ex.Message) End Try
But in the end the Projectnr column has been updated with the Mid(Drow!Projectnr, 1, 10) but..
There is no column with the name Activity????
Does anyone know what I'm doing wrong here?




Reply With Quote