Hi! I'm having a problem in database.. I have this SQL for my vb.net project

Sql = "SELECT STUDENTS.stud_id, STUDENTS.stud_no, [stud_last] & '" & Me.Label1.Text & "' & [stud_first] AS Expr1, STUDENTS.gender00, STUDENTS.course00, SECTION00.sec_code, STUDENTS.Q1, STUDENTS.Q2, STUDENTS.Q3, STUDENTS.Q4, STUDENTS.Q5, STUDENTS.Q6, STUDENTS.Q7, STUDENTS.Finals, STUDENTS.username00, STUDENTS.stud_id FROM SECTION00 INNER JOIN STUDENTS ON SECTION00.sec_id = STUDENTS.sec_id WHERE sec_code LIKE '" & cmd_section.Text & "' AND stud_last LIKE '" & TextBox1.Text & "' ORDER BY STUDENTS.stud_last"

you can see the Expr1 where there is stud_last and stud_first, but when i have it for the search button to search and view the student by its last name, and it doesn't work.. Please help..

Edited 4 Years Ago by chotep: magulo

In what way doesn't it work? Are you getting incorrect data? Are you getting an error message? Please post the actual string value of the variable, Sql.

        Call connector()
        conn.Open()

        Dim sec As String
        sec = cmd_section.Text

        Sql = "SELECT STUDENTS.stud_id, STUDENTS.stud_no, [stud_last] & '" & Me.Label1.Text & "' & [stud_first] AS Expr1, STUDENTS.stud_last, STUDENTS.gender00, STUDENTS.course00, SECTION00.sec_code, STUDENTS.Q1, STUDENTS.Q2, STUDENTS.Q3, STUDENTS.Q4, STUDENTS.Q5, STUDENTS.Q6, STUDENTS.Q7, STUDENTS.Finals, STUDENTS.username00, STUDENTS.stud_id FROM SECTION00 INNER JOIN STUDENTS ON SECTION00.sec_id = STUDENTS.sec_id WHERE sec_code LIKE '" & cmd_section.Text & "' AND Expr1 LIKE '" & TextBox1.Text & "' ORDER BY STUDENTS.stud_last"

        da = New OleDb.OleDbDataAdapter(Sql, conn)
        da.Fill(ds, "RECORD")
        ListView1.Items.Clear()
        For inc = 0 To ds.Tables("RECORD").Rows.Count - 1
            Dim item As New ListViewItem : item.Text = ds.Tables("RECORD").Rows(inc).Item(1)
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(2))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(4))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(5))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(6))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(7))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(8))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(9))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(10))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(11))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(12))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(13))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(14))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(15))
            item.SubItems.Add(ds.Tables("RECORD").Rows(inc).Item(0))
            ListView1.Items.Add(item)
        Next inc
        conn.Close()

here is my actual code. and it highlightened error is the :

da.Fill(ds, "RECORD")

and it says :
No value given for one or more required parameters.

Please reread the previous post where I said

Please post the actual string value of the variable, Sql

I need to see the same query string that is being passed to the DBMS

I don't get it, what kind of variable are you actually looking for?

I need to see the same query string that is being passed to the DBMS

the same query string is also just like the SQL in my code, i've just added the WHERE statement so it can be filtered by its last name and its section. OK. here is the actual query on DB.

SELECT STUDENTS.stud_id, STUDENTS.stud_no, [stud_first] & " " & [stud_last] AS Expr1, STUDENTS.stud_last, STUDENTS.gender00, STUDENTS.course00, SECTION00.sec_code, STUDENTS.Q1, STUDENTS.Q2, STUDENTS.Q3, STUDENTS.Q4, STUDENTS.Q5, STUDENTS.Q6, STUDENTS.Q7, STUDENTS.Finals, STUDENTS.sec_id
FROM SECTION00 INNER JOIN STUDENTS ON SECTION00.sec_id = STUDENTS.sec_id
ORDER BY STUDENTS.stud_last;

it just doesn't seem right that the Expr1 can be filtered by stud_last? please help.

Your variable, Sql, contains the exact query string that is passed to the database server. I need to see the contents of that string.

Basically, put a break point on the line where your SQL string is populated, go into debug mode - it will stop at the breakpoint, add a watch to the SQL string, copy the value for the SQL string out and paste on to the forum.

This article has been dead for over six months. Start a new discussion instead.