buongiorno a tutti,
ho creato due ws con il metodo handlespecialURL.
il primo funziona tranquillamente, ossia questo qui:
Dim db As New MSSQLServerDatabase
db.Host =host // or just the IP if using the default instance
db.DatabaseName = dbnm
db.UserName = user // or "Domain\\UserID for trusted domain accounts
db.Password = pass
If db.Connect Then
Dim stringa_sql as string
stringa_sql="select USERWEB,PWDUWEB,DBNAME from Credenziali where "+parametri
Dim ps As MSSQLServerPreparedStatement
ps = db.Prepare(stringa_sql)
Dim rs As RecordSet = ps.SQLSelect
dim item as new JSONItem
dim numrec as Integer
numrec=0
if rs <> Nil Then
While Not rs.EOF
numrec=numrec+1
dim d as new Dictionary
d.Value("USERWEB") = rs.IdxField(1).StringValue
d.Value("PWDUWEB") = rs.IdxField(2).StringValue
d.Value("DBNAME") = rs.IdxField(3).StringValue
item.Insert(numrec,d)
rs.MoveNext
Wend
rs.Close
End If
db.Close
Return item // And return it to the caller
Else
MsgBox("Connection error:" + db.ErrorMessage)
End If
il secondo, invece, non mi torna nulla, neanche il JSON vuoto, eppure mi sembrano abbastanza simili come logica, ecco il secondo:
Dim db As New MSSQLServerDatabase
db.Host =host // or just the IP if using the default instance
db.DatabaseName = "FS_School" 'dbnm
db.UserName = user // or "Domain\\UserID for trusted domain accounts
db.Password = pass
If db.Connect Then
Dim stringa_sql as string
stringa_sql= "select CODSTUDE,COGSTUDE,NOMSTUDE FROM ANA_STUD WHERE CODSTUDE='0000010028'"
Dim ps As MSSQLServerPreparedStatement
ps = db.Prepare(stringa_sql)
Dim rs As RecordSet = ps.SQLSelect
dim item as new JSONItem
dim numrec as Integer
numrec=0
if rs <> Nil Then
While Not rs.EOF
numrec=numrec+1
dim a as new Dictionary
a.Value("CODSTUDE") = rs.IdxField(1).StringValue
a.Value("COGSTUDE") = rs.IdxField(2).StringValue
a.Value("NOMSTUDE") = rs.IdxField(3).StringValue
item.Insert(numrec,a)
rs.MoveNext
Wend
rs.Close
End If
db.Close
Return item // And return it to the caller
Else
MsgBox("Connection error:" + db.ErrorMessage)
End If
questo invece come vengono chiamate in handlespecialurl
dim data as string = Request.Entity.DefineEncoding(encodings.UTF8) // We have to apply the right encoding to the received data
dim input as JSONItem = new JSONItem( data ) // Creating a new JSON object from it
dim output as JSONItem
Select Case Request.Path // What is the method received as part of the request? (URL)
case "GetUser"
' isoliamo i parametri
parametri = NthField(Request.QueryString, "&", 1)+" and "+NthField(Request.QueryString, "&", 2)
parametri = ReplaceAll (parametri,"%27","'")
output = GetUser // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
case "GetAunni"
output = GetAlunni // Assign the processed data to the output variable, if the received method is 'GetAllAlbums'
Request.Print( output.ToString ) // And send it back to the client that made the request, converting the JSON to a String in first place
end select
Return true
quale pu essere il problema?