Dropdownlist,DataTextField,DataValueField ?

S

Sam

I want to create dropdownlist where DataTextField and DataValueField are
extract from table gldate.

Example
Dropdownlist -> Jan-2005
-> Feb-2005
...
...
-> Dec-2005

Table gldate
============
DataTextField DataValueField
--------------------------------
Jan-2005 200501
Feb-2005 200502
.... ...
.... ...
Dec-2005 200512


Error
=====
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30188: Declaration expected.

Source Error:
Line 5: Dim cnSQL as New System.Data.SqlClient.SqlConnection()
Line 6:
Line 7: cnSQL.ConnectionString = "Password=88;Persist Security Info=True;
User ID=88;Initial Catalog=JDE_ERP_ARCHIVAL;Data Source=SQLSVR"
Line 8:
Line 9: cnSQL.Open()

Source File: C:\Documents and Settings\samuellai\My
Documents\Header\NewFile.aspx Line: 7


Search.aspx
===========
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Dim cnSQL as New System.Data.SqlClient.SqlConnection()

cnSQL.ConnectionString = "Password=88;Persist Security Info=True; User
ID=88;Initial Catalog=JDE_ERP_ARCHIVAL;Data Source=SQLSVR"

cnSQL.Open()

Dim GLDate as New SQLCommand ("select * from gldate",cnSQL)

Dim dr as SQLDataReader = GLDate.ExecuteReader

Do While dr.Read

End DO

dr.Close
GLDate = Nothing
dr = Nothing

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DropDownList id="DropDownList1" runat="server"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" DataSource="<%#
SqlDataSourceControl2 %>" DataTextField="gl_date"
DataValueField="gl_date"></asp:DropDownList>
</form>
</body>
</html>


Please advise.

Many thanks.
 
E

Eliyahu Goldin

A server script on the page can contain member declarations only, in the
same way as a class can. You should declare a method and put he code inside
the method.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top