Can you guys please tell me whats wrong on my code. Im trying to get the data of Title, Author, Price, Stock from DB and output it on my textboxes.

  Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        connstring = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Csrp2_DB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
        conn.ConnectionString = connstring



        If TextBox6.Text = form1.TextBox6.Text Then
            sql = "SELECT from Csrp2_table1 (Title, Author, Price, Stock) Values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')"

            MsgBox("BZZ")
        Else
            MsgBox("FAILs")
        End If


        Dim da As New SqlDataAdapter(sql, conn)

        conn.Open()
        da.Fill(ds)
        conn.Close()
    End Sub

Or do you guys think im missing this code

" WHERE RFID = '" textbox6.text " ' " 

but where should i put it???

Recommended Answers

All 4 Replies

you want to show output from the database and show it in your textbox ? if yes then you can use sqldatareader for this.

Regards

I think you want print it data in text box then you have to use the code like This

   myConnection = New SqlConnection(connectionstring)
        myConnection.Open()

        myCommand = New SqlCommand(" Select (Coloums) FROM (Table) Where P_Id='" & TextBox3.Text & "'", myConnection)
        Dim dr As SqlDataReader = myCommand.ExecuteReader
        While dr.Read()
' In here put textbox to retrive the data from the tabb\le
            TextBox4.Text = Val(dr(0))

            'currentbalance = Double.Parse(dr(2).ToString)

        End While
        dr.Close()
        myConnection.Close()

Hey Dili1234 thank you so much for the effort posting that code. But i already got it to worked, found some code somewhere posted by CodeRaker. I appreciate your effort. Thanks a lot.

You are mostly welcome

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.