我有表waw
id | month | 2015 | 2014 | 2013 |
1 | january | 2 | 4 | 6 |
2 | february | 10 | 12 | 14 |
3 | march | 16 | 18 | 20 |
我有一个查询select "2014" from waw where month ='february'
,结果是12
。
我希望在vb.net
中执行此查询可以帮助我。
答案 0 :(得分:0)
问题有点不清楚(至少对我而言),请尝试这样:
我假设您使用 Npgsql 作为 .Net数据提供商
Imports Npgsql
Private Sub foo()
Using conn As New NpgsqlConnection("pg_conn_string")
Dim retVal As Integer
Dim cmd As New NpgsqlCommand("", conn)
conn.Open()
cmd.CommandText = "select 2014 from waw where month ='february';"
retVal = cmd.ExecuteScalar
End Using
End Sub
您可以使用ExecuteScalar,因为您只想获得一个值