我试图通过按钮点击事件执行一个简单的功能,但我尝试了很多变化,但无法使其工作。 [英] I am trying to execute a simple function with a button click event, but Ive tried many variations and can't make it work.
本文介绍了我试图通过按钮点击事件执行一个简单的功能,但我尝试了很多变化,但无法使其工作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用VS 2010和SQLServer 2008 R1将SQLServer的结果导入我的ASPX页面。函数返回的值为0,这是不正确的,它应该是2.我将不胜感激您提供的任何帮助。 ............ Phil Hoop
Calling事件是这个Button Click事件:
I'm using VS 2010 and SQLServer 2008 R1 to get a result from SQLServer into my ASPX page. The Function is returning a value of 0 which is incorrect, it should be 2. I would appreciate any help you care to provide. ............Phil Hoop
The Calling event is this Button Click event:
'***********************************************************************************************
Private SubbtnContinueImportInst_Click(sender AsObject, e AsSystem.EventArgs) HandlesbtnContinueImportInst.Click
DimmiCountDups AsInt32
iCountDups = CountInstlDups()
Me.LabelDups.Visible = True
Me.LabelDups.Text = iCountDups.ToString
EndSub
'********************************************************************************************
调用的函数是:
The Function called is:
'************************************************************************************************
PublicFunctionCountInstlDups() AsInt32
DimDupcount AsInt32
DimstrImportQuery AsString
strImportQuery = "Select Count (ImportInstitutionsID) "
strImportQuery = strImportQuery & "FROM tmpImportInstutions"
Me.LabelError.Text = "Testing InstDups"& strImportQuery
DimImportconnstring AsString= ConfigurationManager.ConnectionString.("ApplicationServices").ConnectionString
UsingImportconn AsNewSqlConnection(Importconnstring)
DimImportcmd AsNewSqlCommand(strImportQuery, Importconn)
Try
Importconn.Open()
Dupcount = Convert.ToInt32(Importcmd.ExecuteScalar())
Catchex AsException
EndTry
EndUsing
ReturnDupcount
EndFunction
'*************************************************************************************************
推荐答案
我在From子句中错误拼写了表名.......... ....... Phil Hoop
I misspelled the Table name in my From clause.................Phil Hoop
这篇关于我试图通过按钮点击事件执行一个简单的功能,但我尝试了很多变化,但无法使其工作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文