I want to create a script that reads all user info of all users in my domain server and then puts it in a table in my sql server. the problem is i have to modify the object that i get. now when i want to write strings back to the DB i get an error saying type mismatch. So i have to cast a string back to an object but how do you do that??
the strings that i get from the objects are from the format
"sirname, forname"
"Location, kostenstelle, abteilung"
here's the code
MyCommand.CommandText = "INSERT INTO [Employee2] ([Username], [VoorNaam], [Achternaam], [Location], [Kostenstelle], [Abteilung], [Description]) VALUES(?,?,?,?,?,?,?)"
MyCommand.CommandType = 1
imyVar = 0
For Each oADobject In oDomain
strFullName = oADobject.FullName
iFullNamePos = InStr(strFullName, ",")
if (iFullNamePos = 0) then
strVoorNaam = trim(StrFullName)
strnaam = ""
else
iFullNamePos = iFullNamePos-1
strNaam = Left(strFullName, iFullNamePos )
strNaam = Trim(strNaam)
strVoorNaam = Right(strFullName, (len(strFullName) - iFullNamePos-1))
strVoorNaam = Trim(strVoorNaam)
end if
strFullDescription = oADobject.Description
iDescPos1 = Instr(strFullDescription, ",")
if (iDescPos1=0) then
strDescr = strFullDescription
strLocation = ""
strKostenStelle = ""
strAbteilung = ""
else
strDescr =""
iDescPos1 = iDescPos1 - 1
iDescPos2 = InstrRev(strFullDescription, ",")
iDescPos2 = iDescPos2 - 1
strLocation = Left(strFullDescription , iDescPos1)
strKostenStelle = Mid (strFullDescription, iDescPos1 + 3, (iDescPos2 - iDescPos1 - 2) )
strAbteilung = Right (strFullDescription, (len(strFullDescription) - iDescPos2 -2))
End If
MyCommand.Parameters(0).Value = oADobject.Name
MyCommand.Parameters(1).Value = strVoorNaam
MyCommand.Parameters(2).Value = strNaam
MyCommand.Parameters(3).Value = strLocation
MyCommand.Parameters(4).Value = strKostenStelle
MyCommand.Parameters(5).Value = strAbteilung
MyCommand.Parameters(6).Value = strDescr
MyCommand.Execute
imyVar = imyVar+1
Next
any help would be very appreciated
the strings that i get from the objects are from the format
"sirname, forname"
"Location, kostenstelle, abteilung"
here's the code
MyCommand.CommandText = "INSERT INTO [Employee2] ([Username], [VoorNaam], [Achternaam], [Location], [Kostenstelle], [Abteilung], [Description]) VALUES(?,?,?,?,?,?,?)"
MyCommand.CommandType = 1
imyVar = 0
For Each oADobject In oDomain
strFullName = oADobject.FullName
iFullNamePos = InStr(strFullName, ",")
if (iFullNamePos = 0) then
strVoorNaam = trim(StrFullName)
strnaam = ""
else
iFullNamePos = iFullNamePos-1
strNaam = Left(strFullName, iFullNamePos )
strNaam = Trim(strNaam)
strVoorNaam = Right(strFullName, (len(strFullName) - iFullNamePos-1))
strVoorNaam = Trim(strVoorNaam)
end if
strFullDescription = oADobject.Description
iDescPos1 = Instr(strFullDescription, ",")
if (iDescPos1=0) then
strDescr = strFullDescription
strLocation = ""
strKostenStelle = ""
strAbteilung = ""
else
strDescr =""
iDescPos1 = iDescPos1 - 1
iDescPos2 = InstrRev(strFullDescription, ",")
iDescPos2 = iDescPos2 - 1
strLocation = Left(strFullDescription , iDescPos1)
strKostenStelle = Mid (strFullDescription, iDescPos1 + 3, (iDescPos2 - iDescPos1 - 2) )
strAbteilung = Right (strFullDescription, (len(strFullDescription) - iDescPos2 -2))
End If
MyCommand.Parameters(0).Value = oADobject.Name
MyCommand.Parameters(1).Value = strVoorNaam
MyCommand.Parameters(2).Value = strNaam
MyCommand.Parameters(3).Value = strLocation
MyCommand.Parameters(4).Value = strKostenStelle
MyCommand.Parameters(5).Value = strAbteilung
MyCommand.Parameters(6).Value = strDescr
MyCommand.Execute
imyVar = imyVar+1
Next
any help would be very appreciated