viewpoint-particle

Author Topic: mssql error 1261 com/clr exeption  (Read 529 times)

pamsniffer

  • Newbie
  • *
  • Posts: 30
mssql error 1261 com/clr exeption
« on: April 17, 2017, 09:46:32 am »
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

  • Tech Support
  • *****
  • Posts: 2223
    • WinBatch
Re: mssql error 1261 com/clr exeption
« Reply #1 on: April 17, 2017, 11:23:21 am »
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.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


stanl

  • Pundit
  • *****
  • Posts: 668
Re: mssql error 1261 com/clr exeption
« Reply #2 on: April 17, 2017, 12:26:09 pm »
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

  • Newbie
  • *
  • Posts: 30
Re: mssql error 1261 com/clr exeption
« Reply #3 on: April 19, 2017, 12:55:30 am »
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

  • Tech Support
  • *****
  • Posts: 2223
    • WinBatch
Re: mssql error 1261 com/clr exeption
« Reply #4 on: April 19, 2017, 07:59:59 am »
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates