执行数据到gridview ASP.net [英] Execute Data to gridview ASP.net
本文介绍了执行数据到gridview ASP.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,程序员,请在此处查看即时消息.我知道我的语法是错误的.这是我的代码
hello programmers, see im new here. I know my syntax is error. here is my code
<pre lang="vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If drpcc.Text = "CCXXXXX" Then
Dim strSQL As String
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("Data Source=ML0003135586;Integrated Security=SSPI;" & "Initial Catalog=TestSQL")
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", "CCXXXXX")
TPdataCCXXXXX.DataSource = myCommand.ExecuteReader()
TPdataCCXXXXX.DataBind()
End If
End Sub
我认为香港专业教育学院在@CostCenter的参数上出现错误.
你能告诉我语法是什么吗?
感谢
i think ive got an error on parameters on @CostCenter.
could you tell me what the syntax is
thanks
推荐答案
尝试此
try this
strSQL = "SELECT [ID], [CourseTitle], [CourseCode], [Objectives], [Duration] FROM [tblTrainingPlan] WHERE ([CostCenter] =" + @CostCenter + ")";
//You need to concat your Query with [Parameters] other wise it will take it as "string";
这篇关于执行数据到gridview ASP.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文