|
FOROS PROFESIONALES WINDEV, WEBDEV y WINDEV Mobile |
| | | | | |
| Iniciado por Andrea Chiadò Piat, 11,may. 2020 16:27 - No hay respuesta |
| |
| | | |
|
| |
Miembro registrado 62 mensajes |
|
| Publicado el 11,mayo 2020 - 16:27 |
Hi all, anyone has experiences with Dot Net Providers with Windev to connect to database systems? I'm trying to use .net and I can read and write data but when I use parameters in my sql query I always get "ambiguous match found" dot net error! I tried to change a little bit of everything but I don't understand what the problem is. I'm using .net FirebirdSQL provider in this example, but I tried with Postgres and AS400 on WD24 and WD25, with the same results. ADO documentation on parameters seems to be simple but I don't know if in Windev I have to do something more... If anyone can help me out, it would be really appreciated 
Tnx, Andrea
I post my test code:
If bUseParameter=false all is OK If bUseParameter=true I get the error // Failure reading <Parameters> control of <FbCommand> type // Error returned by .NET Framework: // ambiguous match found
PROCEDURE TestDotNetProvider(bUseParameter is boolean)
clConnStr is FbConnectionStringBuilder
clConnStr.DataSource="192.168.1.1" clConnStr.Database="C:\Db\MyDb.fdb" clConnStr.UserID="sysdba" clConnStr.Password="masterkey"
clMyconn is FbConnection
clMyconn.ConnectionString=clConnStr.ToString()
clMyconn.Open()
clSql is FbCommand
clSql<-clMyconn.CreateCommand()
clSql.CommandType=System.Data.CommandType.Text
IF bUseParameter THEN // Here the error clSql.Parameters.Clear()
// Failure reading <Parameters> control of <FbCommand> type // Error returned by .NET Framework: // ambiguous match found
clSql.CommandText="SELECT * FROM mytable WHERE mykey=:mykeyvalue" pclParam is FbParameter pclParam<-clSql.CreateParameter() pclParam.ParameterName=":mykeyvalue" pclParam.Value="somevalue" // Here the error clSql.Parameters.Add(pclParam)
// Failure reading <Parameters> control of <FbCommand> type // Error returned by .NET Framework: // ambiguous match found ELSE clSql.CommandText="SELECT * FROM mytable WHERE mykey='somevalue'" END
pclDati is FbDataReader dynamic
pclDati<-clSql.ExecuteReader()
Trace("Number of fields: "+pclDati.FieldCount)
sFieldName, sFieldType is string vFieldValue is Variant
WHILE pclDati.Read() FOR i=0 _TO_ pclDati.FieldCount-1 sFieldName=pclDati.GetName(i) sFieldType=pclDati.GetDataTypeName(i)
IF pclDati.IsDBNull(i) THEN vFieldValue="" ELSE vFieldValue=pclDati.GetValue(i) END
Trace(pclDati.GetName(i)+": Type:"+pclDati.GetDataTypeName(i)+" - Value: "+vFieldValue) END END
clMyconn.Close() |
| |
| |
| | | |
|
| | | | |
| | |
| | |
| |
|
|
|