mssql error 1261 com/clr exeption

Started by pamsniffer, April 17, 2017, 09:46:32 AM

Previous topic - Next topic

pamsniffer

maybe someone can help me.

I have type to change this script to MSSQL database instead of msaccess
but i get the error com/clr exeption


dbname  = StrCat(DirScript(), "Master.mdf")
DEBUG(@ON)
adInteger      = 3
adVarWChar     = 202
adVarMemo     = 203
svr = ".\SQLEXPRESS"
db = "Master.mdf"
connStr ="Provider=SQLOLEDB.1;Data Source=":svr:";Database=":db:";Integrated Security=SSPI;Persist Security Info=False"

adoxTable = ObjectCreate("ADOX.Table")
adoxTable.Name = "JAAP"
adoxCatalog = ObjectCreate("ADOX.Catalog")
adoxCatalog.Create(connStr)
adoxTable.Columns.Append("Number", adInteger, 4)
adoxTable.Columns.Append("Servername", adVarWChar, 20)
adoxTable.Columns.Append("data", adVarMemo, 10)
adoxTable.Columns.Append("risk", adVarWChar, 30)
adoxCatalog.Tables.Append(adoxTable)

; ADO Connect
adoConn = ObjectCreate("ADODB.Connection")
adoConn.open(connStr)

; ADO has a separate recordset object, which requires a string
; to select which records and which table we want to work with, which connection
; to use and how we want to setup the recordset object...
rs = ObjectCreate("ADODB.Recordset")
sqlstr = "Select * from  JAAP"
rs.Open(sqlstr, adoConn, 1,4,1)

file="jaap.log"
file=strlower(file)

; Allocate a buffer much larger than required.
bb=BinaryAlloc(FileSize(file)*4)
structure=BinaryTagInit(bb,"BEGINRECORD","ENDRECORD")
BinaryEodSet(bb,0)
aa=""
BinaryRead(bb,file)

xx=100
While 1
   structure=BinaryTagFind(structure)
   If structure=="" Then Break ; All done
   data=BinaryTagExtr(structure,0)
   
   aa=xx
     
      rs.addnew
      ;   Add in each field...
      rs.fields("Number").value    =  "%aa%"
      rs.fields("Servername").value =  "test_server"
      rs.fields("data").value       =  strcat(data)
      rs.fields("risk").value       = "none"

      rs.updateBatch

   xx=xx+1
EndWhile

BinaryFree(bb)
rs.close
rs = 0
db = 0
adoConn = 0
adoxCatalog = 0
adoxTable = 0

Exit


td

Please provide the line that is causing the error and any contents display when you click the the More Error Info button if it is enabled when the error message is displayed.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Why are you opening an .mdf file; cannot you reference Master as a table in SQL Server? If your issue is later in the code, you might want to move rs.updatebatch out of the loop, or use rs.update instead.

pamsniffer

The error i received is

com/clr exeption

provider
interface is not supported

I have changed the code


bname  = StrCat(DirScript(), "Model")
DEBUG(@ON)
adInteger      = 3
adVarWChar     = 202
adVarMemo     = 203
svr = ".\SQLEXPRESS"
db = "Model"
connStr ="Provider=SQLOLEDB;Data Source=":svr:";Database=":db:";Integrated Security=SSPI;Initial Catalog=master"

                                                     



adoxTable = ObjectCreate("ADOX.Table")
adoxTable.Name = "JAN"
adoxCatalog = ObjectCreate("ADOX.Catalog")
adoxCatalog.Create(connStr)
adoxTable.Columns.Append("Number", adInteger, 4)
adoxTable.Columns.Append("Servername", adVarWChar, 20)
adoxTable.Columns.Append("data", adVarMemo, 10)
adoxTable.Columns.Append("risk", adVarWChar, 30)
adoxCatalog.Tables.Append(adoxTable)

; ADO Connect
adoConn = ObjectCreate("ADODB.Connection")
adoConn.open(connStr)

; ADO has a separate recordset object, which requires a string
; to select which records and which table we want to work with, which connection
; to use and how we want to setup the recordset object...
rs = ObjectCreate("ADODB.Recordset")
sqlstr = "Select * from JAN"
rs.Open(sqlstr, adoConn, 1,4,1)

file="sps430.CAS-filesys.log"
file=strlower(file)

; Allocate a buffer much larger than required.
bb=BinaryAlloc(FileSize(file)*4)
structure=BinaryTagInit(bb,"BEGINRECORD","ENDRECORD")
BinaryEodSet(bb,0)
aa=""
BinaryRead(bb,file)

xx=100
While 1
   structure=BinaryTagFind(structure)
   If structure=="" Then Break ; All done
   data=BinaryTagExtr(structure,0)
   
   aa=xx
     
      rs.addnew
      ;   Add in each field...
      rs.fields("Number").value    =  "%aa%"
      rs.fields("Servername").value =  "test_server"
      rs.fields("data").value       =  strcat(data)
      rs.fields("risk").value       = "none"

      rs.updateBatch

   xx=xx+1
EndWhile

BinaryFree(bb)
rs.close
rs = 0
db = 0
adoConn = 0
adoxCatalog = 0
adoxTable = 0

Exit




td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade