Click here to Skip to main content
15,883,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 1 table name product( product_id,name,description,amt,broker_id)

broker_id is the foreign key in this table.

now i want on selection of broker_id from combobox, i will insert data into textbox which will get updated in database.

how do i do that?

VB
Dim cn As New SqlConnection("Data Source=.\INSTANCE;initial catalog=stamp;user=sa;password=gariahat")
        Dim da As New SqlDataAdapter
        Dim cmd As New SqlCommand
        Dim ds As New DataSet
        'Dim dr As SqlDataReader
        cmd.Connection = cn
        cn.Open()
        cmd.CommandText = "Update product set " & "product_id = '" & TextBox1.Text & "', " & "pname='" & RichTextBox1.Text & " '," & "description='" & RichTextBox2.Text & " '," & "amt='" & TextBox2.Text & "' " & "Where broker_id = '" & ComboBox1.SelectedItem & "'"
        cmd.ExecuteNonQuery()
        MsgBox("Data successfully added", MsgBoxStyle.Information)
        TextBox1.Text = ""
        TextBox2.Text = ""
        RichTextBox1.Text = ""
        RichTextBox2.Text = ""
Posted
Updated 28-Jul-13 23:03pm
v2
Comments
sudeshna from bangkok 29-Jul-13 5:00am    
Dim cn As New SqlConnection("Data Source=.\INSTANCE;initial catalog=stamp;user=sa;password=gariahat")
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim ds As New DataSet
'Dim dr As SqlDataReader
cmd.Connection = cn
cn.Open()
cmd.CommandText = "Update product set " & "product_id = '" & TextBox1.Text & "', " & "pname='" & RichTextBox1.Text & " '," & "description='" & RichTextBox2.Text & " '," & "amt='" & TextBox2.Text & "' " & "Where broker_id = '" & ComboBox1.SelectedItem & "'"
cmd.ExecuteNonQuery()
MsgBox("Data successfully added", MsgBoxStyle.Information)
TextBox1.Text = ""
TextBox2.Text = ""
RichTextBox1.Text = ""
RichTextBox2.Text = ""
sudeshna from bangkok 29-Jul-13 5:01am    
this is my code,but its not working. at present in database no records are there.
sudeshna from bangkok 29-Jul-13 5:01am    
please can anyone help me.its urgent
Maciej Los 29-Jul-13 8:12am    
Urgent - OK, but... your question is not clear enough ;(
sudeshna from bangkok 29-Jul-13 5:19am    
can anyone help plz

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900