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:
<aspropDownList id="DropDownList2" runat="server">
<asp:ListenItem>Thriller</asp:ListenItem>
<asp:ListenItem>Horror</asp:ListenItem>
<asp:ListenItem>Sci-fi</aps:ListenItem>
</aspropDownList>
and the code? I want to write this values in the database...
Bye
Stefano from Italy
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:
<aspropDownList id="DropDownList2" runat="server">
<asp:ListenItem>Thriller</asp:ListenItem>
<asp:ListenItem>Horror</asp:ListenItem>
<asp:ListenItem>Sci-fi</aps:ListenItem>
</aspropDownList>
and the code? I want to write this values in the database...
Bye
Stefano from Italy