Hi guys, got a problem here. As you see I created a dropdownlist where the datafield will be on the database. Codes are as follow
Dim drop As String
drop = "SELECT * FROM [CourseCode]"
connection.Open()
Dim ddDr As SqlClient.SqlDataReader
Dim ddSqlCommand As New SqlClient.SqlCommand(drop, connection)
ddDr = ddSqlCommand.ExecuteReader(CommandBehavior.CloseConnection)
drpProCode.DataSource = ddDr
drpProCode.DataTextField = "Course_Code"
drpProCode.DataValueField = "Course_Code"
drpProCode.DataBind()
connection.Close()
After that I created another table where the dropdownlist data will be added. Here is the code:
DBCmd = New SqlClient.SqlCommand("INSERT INTO tblCourses_13514(Course_Code, Course_Title, Objectives, Category, Duration ) VALUES (@Course_Code, @Course_Title, @Objectives, @Category, @Duration)", DBConn)
DBCmd.Parameters.Add("@Course_Code", SqlDbType.NVarChar).Value = drpProCode.Text
DBCmd.Parameters.Add("@Course_Title", SqlDbType.NChar).Value = txtProName.Text
DBCmd.Parameters.Add("@Objectives", SqlDbType.NVarChar).Value = txtProDescription.Text
DBCmd.Parameters.Add("@Category", SqlDbType.NVarChar).Value = drpProCategory.Text
DBCmd.Parameters.Add("@Duration", SqlDbType.NVarChar).Value = txtProDuration.Text
DBCmd.ExecuteNonQuery()
lblProMessage.Text = "Your Proposed Plan was sent for approval"
Now my problem is when I click add, only the first record of the dropdownlist is added even when a choose a different data from it. Plss help me I dont know where the problem is. Thanks in advance and more power!