Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将Flatter应用程序连接到SQL Server以发送查询_Sql_Sql Server_Flutter - Fatal编程技术网

如何将Flatter应用程序连接到SQL Server以发送查询

如何将Flatter应用程序连接到SQL Server以发送查询,sql,sql-server,flutter,Sql,Sql Server,Flutter,我创建了一个带有表的应用程序,应该使用对SQL SERVER的查询来填充表。如何使用应用程序向服务器发送请求?您可以使用 但是,您需要在安装SQLServer的服务器计算机上安装SqlServerSocket // creates a connection var conn = new SqlConnection("SERVER=localhost;Database=mydb;Trusted_connection=yes"); // open connection await conn.op

我创建了一个带有表的应用程序,应该使用对SQL SERVER的查询来填充表。如何使用应用程序向服务器发送请求?

您可以使用

但是,您需要在安装SQLServer的服务器计算机上安装SqlServerSocket

// creates a connection 
var conn = new SqlConnection("SERVER=localhost;Database=mydb;Trusted_connection=yes");

// open connection
await conn.open();

// runs a query returning a single value
var howmany = await conn.queryValue("SELECT COUNT(*) FROM Customers");

// runs a query returning a single row
var myFirstCustomer = await conn.querySingle("SELECT name,age FROM Custormers");
print(myFirstCustomer["name"]);

// runs a query returning all rows
var customers = await conn.query("SELECT TOP 10 name,age FROM Custormers");
for(var customer in customers)
{
   print(customer["name"]);
}

// execute a command, returning the number of rows affected
var n = await conn.execute("UPDATE Customers SET age=0");
print("zeroed $n customers");

// disconnect
await conn.close();

我已经试过这个方法了,它不起作用。