首页 > 解决方案 > Excel阿拉伯语列查询.Net

问题描述

我在列中有带有阿拉伯文本的 Excel 表,当我想在 vb.net 中检索数据时,总是遇到问题:

没有为一个或多个必需参数提供值

代码是这样的:

Dim Dta1 As OleDbCommand
Dim Dta1 As OleDbCommand
Using conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Excel + ";Extended Properties=Excel 12.0;")
    conn.Open()
    Dta2 = New OleDbCommand("Select  Count([إسم الثلاثي للمريض]) From [Sheet1$A:S] GROUP BY  Name HAVING COUNT(*) > 1", conn)
    Dta3 = New OleDbCommand("Select  Count([رقم الهاتف]) From [Sheet1$] GROUP BY  Phone  HAVING COUNT(*) > 1", conn)
    Dim b As Integer = Dta2.ExecuteScalar
    Dim c As Integer = Dta3.ExecuteScalar
End Using

代码停在 Dta2.ExecuteScalar

标签: .netexcelvb.net

解决方案


使用前定义所有变量

dim st1 as String ="إسم الثلاثي للمريض"   
dim st2 as String ="رقم الهاتف" 

Dta2 = New OleDbCommand("Select  Count(st1) From [Sheet1$A:S] GROUP BY  Name HAVING COUNT(*) > 1", conn)
        Dta3 = New OleDbCommand("Select  Count(st2 ) From [Sheet1$] GROUP BY  Phone  HAVING COUNT(*) > 1", conn)

推荐阅读