Hi!
Good Afternoon.
Ur Problem is Solve.
:)
Steps
1:- Create Database
And Create Table
Table Field:
ID
Item
Value
Then Complete Table
2:- Add New Page in Ur Application
Drag Listbox
<asp:ListBox ID="ListBox1" runat="server">
<asp:ListItem Text="house" Value="0"></asp:ListItem>
<asp:ListItem Text="car" Value="1"></asp:ListItem>
<asp:ListItem Text="boat" Value="2"></asp:ListItem>
</asp:ListBox>
Drag Button
<asp:Button ID="btnSave" runat="server" Text="Save" />
Step3:-
Add Name Spaces
Imports System.Data
Imports System.Data.SqlClient
Diclare Globaly Variable
Dim Str As String
Dim Sql As String
Dim Con As New SqlConnection
Dim Cmd As SqlCommand
Button Click Event
Sql = "INSERT INTO TableName(Item,Value) Values(" & ListBox1.SelectedItem.Value & ",'" & ListBox1.SelectedItem.Text & "')"
Con.Open()
Cmd = New SqlCommand(Sql, Con)
Cmd.ExecuteNonQuery()
Con.Close()
Page Load Event
'This ConnectionString(ConStr)Define in Web.Config
Str = System.Configuration.ConfigurationManager.AppSetti ngs("ConStr").ToString
Con = New SqlConnection(Str)
Step4:- Connection String Define in Web.Config Like example.
<appSettings>
<add key="ConStr" value="Data Source=.\SQLEXPRESS;Initial Catalog=Your DatabaseName;Integrated Security=True"/>
</appSettings>
ok
n any query u will contact me
[email protected]
Sandip