ciao a tutti, non riesco a capire perch questa query in xojo ritorna sempre il recordset a nil, mentre in sql server 2008r2 lanciandola funziona…
grazie,
c
//recuperiamo i dati
Dim db As New MSSQLServerDatabase
db.Host ="192.168.7.82" // or just the IP if using the default instance
db.DatabaseName = "FsSchool"
db.UserName ="sa" // or "Domain\\UserID for trusted domain accounts
db.Password = "mypwd"
If db.Connect Then
Dim ps As MSSQLServerPreparedStatement
ps = db.Prepare("SELECT MAX(ANA_STUD.COGSTUDE), MAX(ANA_STUD.NOMSTUDE),MAX(DTA_STUDE.CODFSRED), "_
+"MAX(DTA_STUDE.IMPBUONO), MAX(DTA_STUDE.ISEESTUD),MAX(DTA_STUDE.VALBUONI),"_
+"CASE WHEN MAX(DTA_STUDE.IMPBUONO)>0 THEN CAST((MAX(DTA_STUDE.VALBUONI)/MAX(DTA_STUDE.IMPBUONO)) "_
+" AS decimal(4,0)) ELSE 0 END AS PASTIRESIDUI, "_
+"SUM(CASE WHEN MOV_BUON_m.TIPOMOVI='CS' THEN MOV_BUON.VALORTOT ELSE 0 END) as CARICHI,"_
+"SUM(CASE WHEN MOV_BUON_m.TIPOMOVI='SS' THEN MOV_BUON.VALORUNI ELSE 0 END) as SCARICHI, "_
+"SUM(CASE WHEN MOV_BUON_m.TIPOMOVI='SS' THEN 1 ELSE 0 END) as PASTIFRUITI"_
+"FROM DTA_STUDE INNER JOIN ANA_STUD ON DTA_STUDE.CODSTUDE = ANA_STUD.CODSTUDE "_
+"INNER JOIN MOV_BUON ON DTA_STUDE.CODSTUDE = MOV_BUON.CODSTUDE "_
+"INNER JOIN MOV_BUON_m ON MOV_BUON.SERIALEM = MOV_BUON_M.SERIALEM "_
+"WHERE DTA_STUDE.CODSTUDE = ? AND DTA_STUDE.CODANNSC = ?")
ps.BindType(0, MSSQLServerPreparedStatement.MSSQLSERVER_TYPE_STRING)
ps.BindType(1, MSSQLServerPreparedStatement.MSSQLSERVER_TYPE_STRING)
ps.Bind(0, AlunnoSel)
ps.Bind(1, Login_Page.SpAnnoSco.Text)
Dim rs As RecordSet = ps.SQLSelect
// FACCIAMO VEDERE I VALORI DEGLI ALTRI CAMPI
if rs <> Nil Then
While Not rs.EOF
TxtCognome.Text=rs.IdxField(1).StringValue
TxtNome.Text=rs.IdxField(2).StringValue
TxtFascia.Text=rs.IdxField(3).StringValue
TxtImpBuono.text=rs.IdxField(4).StringValue
TxtIsee.text=rs.IdxField(5).StringValue
TxtSaldo.Text=rs.IdxField(6).StringValue
TxtPastiSaldo.Text=rs.IdxField(7).StringValue
TxtCarichi.Text=rs.IdxField(8).StringValue
TxtScarichi.Text=rs.IdxField(9).StringValue
TxtPastiFruiti.Text=rs.IdxField(10).StringValue
rs.MoveNext
Wend
rs.Close
End If
db.Close
//assegniamo la variabile, mi servir per dopo
me.Show
Else
MsgBox("Connection error:" + db.ErrorMessage)
End If