带vb编码的asp.net [英] asp.net with vb Coding

查看:87
本文介绍了带vb编码的asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在类中给出编码

i give the coding in class

Public sub fill_combo(byval ddl as dropdownlist,byval field as string,byval condition s string)
dim dr as sqldatareader
dim a() as string
ddl.items.clear()
dim l as new listitem
l.text="select "
l.value=0
ddl.items.add(l)
dr=viewrecord_dr(field,tbl,condition)
if field.contains(",") then
a=field.split(",")
while dr.read
dim li as new listitem
li.value=dr.item(0)
li.text=dr.item(1)
ddl.items.add(li)
end while
else
while dr.read
ddl.items.add(dr.item(0))
end while
end if
dr.close()
end sub


我在课堂上给这个编码


I give this coding in class

Public function viewrecord_dr(byval field as string,byval condition s string)as sqldatareader
dim query as string 
query="select"
query=query+"from "+tbl
if condition.trim.length>0 
else
query=query
end if
cmd=new sqlcommand (query,con)
dr=cmd.excutereader()
viewrecord_dr=dr
end function


我在pageload中给出了此编码


i give this coding in pageload

c.connect()
call c.fill_combo(ddlservicenumber,"servicenumber","tblregistration","")
c.disconnect()


我的错误是无效的列名servicenumberfrom"
请清除此错误


My error is ''invalid column name servicenumberfrom"
please clear this error

推荐答案

用空格隔开我的朋友,

因为您没有任何东西.
您需要一个空格,您需要在"select"和"servicenumber"之间一个空格,您需要在"servicenumber"和"from"之间一个空格.

显式添加空格,如果要汇编这样的字符串,则可以优先使用,请使用StringBuilder,因为它效率更高!
Spaces my friend, spaces.

As in you don''t have any.
You need a space between you need a space between "select" and "servicenumber", you need a space between "servicenumber" and "from".

Add spaces explicitly, and by preference if you are going to assemble strings like that, use a StringBuilder as it is a lot more efficient!


在任何情况下,最后一个函数应看起来像这样:

The last function should look something like this in any case:

Public sub viewrecord_dr(byval field as string,byval condition s string)
dim query as string
query = "select from " & tbl
if tbl = nothing then
exit sub
end if

cmd=new sqlcommand (query,con)
'Where is dr defined?
dr=cmd.excutereader()
'And why not: viewrecord_dr = cmd.excutereader()
viewrecord_dr=dr
end function



您的代码似乎需要很多工作....



Your code looks like it needs a lot of work though....


这篇关于带vb编码的asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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