0

AM I doing the right syntax for this parameter?

            da.SelectCommand = new SqlCommand("SELECT Member.MemberID, Member.Name , Member.Surname, Rentals.RentalID FROM Member,Rentals WHERE Member.MemberID = (@MemberID) Rentals.MemberID", c);

            da.SelectCommand.Parameters.Add("MemberID", SqlDbType.VarChar).Value = txtID.Text;

            ds.Clear();
            da.Fill(ds);
            dtgv1.DataSource = ds;

It is giving me an error "Incorrect syntax near 'Rentals'."

Thanks

Edited by GilbertB

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Mitja Bonca
0
da.SelectCommand = new SqlCommand("SELECT Member.MemberID, Member.Name , Member.Surname, Rentals.RentalID FROM Member,Rentals WHERE Member.MemberID = (@MemberID) Rentals.MemberID", c);

After WHERE Member.MemberID = (@MemberID) There is Rentals.MemberID ? it doesn't make sence there is no need for the Rentals.MemberID at the end of where calue

0

1st of all, dont use any parenthesis.

next do:

"SELECT Member.MemberID, Member.Name , Member.Surname, Rentals.RentalID FROM Member, Rentals WHERE Member.MemberID = Rentals.MemberID AND Member.MemberID = @MemberID"

And define @MemberID parameter as you did (paramtreize query)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.