Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i wrote a query as.


C#
SqlDataAdapter da = new SqlDataAdapter("select users.username,groups.name from users,groups inner join users on roles.userid=users.userid inner join groups on roles.groupid=users.groupid", MAconn); 
but i am getting an error
 

System.NullReferenceException: Object reference not set to an instance of an object. at Default2.bind()
Posted
Comments
Dirk C De Winnaar 9-Sep-11 18:02pm    
Put a break point in and step through to see what gets loaded.
Are you using a table or a DataSet?

Assuming that all tables have the columns referenced in your query, and IDs have the meaning implied by their names, I think this should be a working query.
SQL
select users.username, groups.name
from users
inner join roles on roles.userid=users.userid
inner join groups on roles.groupid=groups.groupid

If you get an exception, could you post more lines from the stack trace?
 
Share this answer
 
v2
Comments
codegeekalpha 9-Sep-11 6:24am    
thx.. for helping me out..
How did you setup MAconn? Did you forget to New it?
 
Share this answer
 
Comments
codegeekalpha 9-Sep-11 6:24am    
yes i forgot.. thx u kschuler

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