Checkbox list into two field in db

tiffany

Well-known member
Joined
Aug 7, 2005
Messages
57
Programming Experience
1-3
Hi, did anyone know how to insert checkbox lists items into two col in db? Which is mean i had three items in checkbox list, when i checked two items among the three. It will insert the two items into two col in db.


I had this code, but it only insert into one col. How to improve this codes to meet my requirement? Urgent. Thnkx

Dim strSQL As String = " INSERT INTO movieDet ([Title], [des], [Year], [actor1], [actor2], [actor3], [actor4], [branch], [section], [section2],[category], [type], [pic]) VALUES('" & tb_title.Text & "','" & tb_des.Text & "','" & tb_year.Text & "','" & tb_actor1.Text & "','" & tb_actor2.Text & "','" & tb_actor3.Text & "','" & tb_actor4.Text & "','" & CheckBoxList1.SelectedValue & "','" & cl_sec.SelectedValue & "','" & cl_sec.SelectedValue & "','" & RadioButtonList2.SelectedValue & "','" & RadioButtonList3.SelectedValue & "','" & Image1.ImageUrl & "')"

Sorry the codes are a little messy. The checkbox list i'm talking about is cl_sec.SelectedValue . And the field i want to fill indb is section and section2. thnk. Urgent!
 
Hi, can anyone please help me the checkbox list. Please, its really urgent.


This follwong codes has a update syntax error:

Dim strConn AsString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("movie.mdb")

Dim strSQL AsString = "UPDATE movieDet SET Title = '" + tb_title.Text + "', price = '" + tb_np.Text + "', des = '" + tb_desc.Text + "', [Year] = '" + tb_yr.Text + "', actor1 = '" + tb_ac1.Text + "' ,actor2 = '" + tb_ac2.Text + "',actor3 = '" + tb_ac3.Text + "', actor4 = '" + tb_ac4.Text + "', branch = '" + ddl_bra.SelectedValue + "',section = '" + ddl_sec.SelectedValue + "',category = '" + ddl_cat.SelectedValue + "', [type] = '" + ddl_type.SelectedValue + "', pic = '" + Image1.ImageUrl + "' Where MovieID = " & tb_id.Text

Dim scnnNW AsNew OleDbConnection(strConn)

Dim scmd AsNew OleDbCommand(strSQL, scnnNW)

Dim dr As OleDbDataReader

Try

scnnNW.Open()

Response.Write(strSQL)

Response.End()

dr = scmd.ExecuteReader()

dr.Close()

Response.Write("Product successfully saved to the database.")

Catch exp As Exception

Response.Write("Error: " & exp.Message)

Finally

scnnNW.Close()

EndTry


Can anyone help me ..the update had a sybtax error.
 
Back
Top