繁体   English   中英

OleDB Conn字符串和VB.net的问题

[英]Issues with OleDB Conn String and VB.net

当我运行以下语句时,我在准则表达式错误中遇到了数据类型不匹配的情况,我将其拆开,在我的生命中无法发现错误所在! 可能是由于我的初学者知识水平,但这是我所能做到的!

这是我的代码;

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    Dim UserName As String
    UserName = System.Environment.UserName
    Dim Month = Date.Now.ToString("MM")
    Dim CS As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("ConnCIM")
    Dim Table As New DataTable
    Dim Adapt As New OleDbDataAdapter("SELECT [LoginName], [DisplayName], [Date], [SessionID], [The wait time was acceptable] , [The length of the chat session was appropriate] , [Professionalism of the agent] , [Effectiveness of the response] , [Overall opinion of the chat service] , [Related Comments] , [Not Resolved Comments] FROM [Chat_Dump] WHERE (([LoginName] = @UserName) AND ([Date] = @Month))", CS.ToString())
    Adapt.SelectCommand.Parameters.AddWithValue("@UserName", Textbox1.text)
    Adapt.SelectCommand.Parameters.AddWithValue("@Month", TextBox2.Text)

    TextBox2.Text = Month


    Adapt.Fill(Table)

    GridView1.DataSource = Table
    GridView1.DataBind()

End Sub 

文本框仅用于测试,文本框1被替换为UserName,而我希望textbox2被Month替换。

简而言之,我有一个数据表,当每个用户查看时,我希望它从域登录中提取其用户名并显示其当月的记录。

谢谢! 非常抱歉,我的知识水平不高!

如果[Date]DATETIME ,则需要从中提取月份,然后与您的月份值进行比较。

... AND MONTH([Date]) = @Month

(整数DateTime.Now.MonthToString("MM")更好)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM