[求助]asp.net中DropDownList控件连接数据库的问题?
哪位大侠帮帮忙啊subpage_load(senderasobject,easeventargs)dimconnstrasstringconnstr="server=lo...
哪位大侠帮帮忙啊
sub page_load(sender as object,e as eventargs)
dim connstr as string
connstr="server=localhost;database=mydata;uid=sa;pwd=....."
dim sqlselect as string
sqlselect="select name from class"
dim myconn as new sqlconnection(connstr)
dim mysqlda as new sqldataadapter(sqlselect,connstr)
dim dt as DataTable
'dim myds as new dataset(dt)
mysqlda.Fill(dt)
DropDownList1.DataSource=dt
DropDownList1.DataTextField="name"
DropDownList1.DataBind()
end sub
这个老是说:值不能为空。
参数名: dataTable
异常详细信息: System.ArgumentNullException: 值不能为空。
参数名: dataTable
行 24: mysqlda.Fill(dt)
到底是错哪了啊,应该怎么改????
谢谢各位指点
前面标记的语句为:<asp:dropdownlist id="dropdownlist1" runat="server" AutoPostBack="True"></asp:dropdownlist> 展开
sub page_load(sender as object,e as eventargs)
dim connstr as string
connstr="server=localhost;database=mydata;uid=sa;pwd=....."
dim sqlselect as string
sqlselect="select name from class"
dim myconn as new sqlconnection(connstr)
dim mysqlda as new sqldataadapter(sqlselect,connstr)
dim dt as DataTable
'dim myds as new dataset(dt)
mysqlda.Fill(dt)
DropDownList1.DataSource=dt
DropDownList1.DataTextField="name"
DropDownList1.DataBind()
end sub
这个老是说:值不能为空。
参数名: dataTable
异常详细信息: System.ArgumentNullException: 值不能为空。
参数名: dataTable
行 24: mysqlda.Fill(dt)
到底是错哪了啊,应该怎么改????
谢谢各位指点
前面标记的语句为:<asp:dropdownlist id="dropdownlist1" runat="server" AutoPostBack="True"></asp:dropdownlist> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询