I am a fresher to .net programming and i have to auto populate the drop down list from the database and also if the user needs to enter afresh data then also it should take that value.
Also i have to write a code for storing the form values into the database on a button click event. i have 3 buttons --> Save Button , Edit button, and Delete button.
i hve tried to write some code but i am not ablke to clean the exceptions raised while i am running the form.
My code goes here:
Protected Sub btn_submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click myConnection = New SqlConnection("Data Source=.\Sqlexpress;Initial Catalog=HRDATA;Integrated Security=True") myConnection.Open() 'cmdtype.CommandType = Data.CommandType.Text 'myCommand = New SqlCommand("Insert into Employee Data values(ddlid.selectedItem,'" & txtname.Text & "',ddldesig.selectedItem,'" & txtcontno & "')", "myConnection") myCommand = New SqlCommand("Insert into Employeedata (ID,Name) values(ddlid.SelectedItem, ' & txtname.Text & ')", myConnection) ra = myCommand.ExecuteNonQuery() 'MsgBox.Show("New Row Inserted" & ra) myConnection.Close() End Sub
any suggestions or any help is greatly appreciated
Thanks in advance,