简体   繁体   中英

parameterized top clause query in asp.net C#

I want to use the top clause query in C#

objConnection = new SqlConnection(ConfigurationManager.AppSettings["connectionstring"].ToString());
            objConnection.Open();
            objCommand = new SqlCommand("SELECT TOP (@perpage) * FROM user_master", objConnection);
            objCommand.Parameters.AddWithValue("@perpage",objusmspass.strperpage);
            objReader = objCommand.ExecuteReader();

I am getting object reference not set to the instance of the object at line

objReader = objCommand.ExecuteReader();

Thanks,

检查您的自定义对象objusmspass及其属性是否为null,使用try catch块查看它是哪种异常(sqlException或其他异常)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM