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

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

The where clause is incorrect.

WHERE Member.MemberID = (@MemberID) AND Rentals.MemberID = Member.MemberID

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)

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.