VB.net中如何将变量赋值为ACCESS查询出来之后的一个具体值

2024-11-21 18:43:27
推荐回答(1个)
回答1:

但用ExecuteScalar就够了,而且效率更高

Dim myDate As string

Dim conn As SqlConnection = New SqlConnection("Server=(local);DataBase=test;Uid=sa;Pwd=123")
Dim sql As String = "SELECT adjustdate FROM plupos AS WHERE barcode = xxx "
Dim cmd As New SqlCommand(sql, conn)
conn.open
myDate=cmd.ExecuteScalar().tostring
conn.Close()