DropDownList and SQL

S

Stefano B*

I'm writing a web page (aspx) to insert data in SQL server database...
I have "free" Textbox and a "conditioned" DropdownList. So i have some
troubles:
The values of Dropdownlist (i insert it manually) it's better in the Htlm
side or code side?? I think it's better the html side so i write for free
textbox

Function MyInsertMethod(ByVal title As String, ByVal Disk_number As
Decimal) As Integer
Dim connectionString As String = "server='servern'; user id='';
password=''; database='test'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "INSERT INTO [Film] ([Title], [Support],
[Disk_number], [Owner]) VALUES (@Title, @Disknumber)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_title As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_title.ParameterName = "@Title"
dbParam_title.Value = title
dbParam_title.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_title)

and it works
The problem is the code for dropdowlist. In htlm i write:

<asp:DropDownList id="DropDownList2" runat="server">
<asp:ListenItem>Thriller</asp:ListenItem>
<asp:ListenItem>Horror</asp:ListenItem>
<asp:ListenItem>Sci-fi</aps:ListenItem>
</asp:DropDownList>

and the code? I want to write this values in the database...

Bye
Stefano from Italy
 

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,787
Messages
2,569,630
Members
45,334
Latest member
66Zeinab9

Latest Threads

Top