关于griview绑定的问题 [英] Problem regarding griview binding

查看:71
本文介绍了关于griview绑定的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里遇到了问题.我不知道我在哪里出错.这是我的代码

<pre lang="vb">Dim strSQL As String
       Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
       strSQL = "SELECT [ID], [CourseTitle], [CourseCode], [Objectives], [Duration] FROM [tblTrainingPlan] WHERE ([CostCenter] = @CostCenter)"
       connection.Open()
       Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, connection)
       myCommand.Parameters.AddWithValue("@CostCenter", 123)
       TPdataCCXXXXX.DataSource = myCommand.ExecuteReader()
       TPdataCCXXXXX.DataBind()



这是错误
Conversion failed when converting the nvarchar value ''CCXXXXX'' to data type int.
请在这里帮助我.感谢和更多的力量

解决方案


我猜你在这方面的错误
myCommand.Parameters.AddWithValue("@ CostCenter",123)
将其更改为myCommand.Parameters.AddWithValue("@ CostCenter","123")


hi guys ive a problem here. I dont know where did i go wrong. here is my code

<pre lang="vb">Dim strSQL As String
       Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=ML0003135586;Initial Catalog=TestSQL;Integrated Security=True")
       strSQL = "SELECT [ID], [CourseTitle], [CourseCode], [Objectives], [Duration] FROM [tblTrainingPlan] WHERE ([CostCenter] = @CostCenter)"
       connection.Open()
       Dim myCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(strSQL, connection)
       myCommand.Parameters.AddWithValue("@CostCenter", 123)
       TPdataCCXXXXX.DataSource = myCommand.ExecuteReader()
       TPdataCCXXXXX.DataBind()



here is the error
Conversion failed when converting the nvarchar value ''CCXXXXX'' to data type int.
please help im new here. thanks and more power

解决方案

Hi,
I guess your error in this area
myCommand.Parameters.AddWithValue("@CostCenter", 123)
Change it to myCommand.Parameters.AddWithValue("@CostCenter", "123")


这篇关于关于griview绑定的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆