如何在asp.net网页中使用数据库字段值 [英] how to use a database field value in an asp.net web page

查看:53
本文介绍了如何在asp.net网页中使用数据库字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的编码员,

我想将特定用户的数据库表中的角色值与使用c#编码在asp.net网页的下拉列表值中选择的角色进行比较.请帮助我解决这个问题.thanx...

Dear Coders,

i want to compare a role value from a database table of a particular user with the role i have selected in dropdown list value in an asp.net web page using c# coding. please help me with the coding part of this.thanx...

推荐答案

这很简单...

在网页中声明一个字符串变量,然后使用executescalar方法运行命令.
it''s simple...

declared a string variable in webpage, then run the command using executescalar method.
string variablename=commandobject.ExecuteScalar().ToString();


query = select role from table where role='selecte_value';


string role=commandobject.ExecuteScalar().ToString();

if (role.equals(''))
{
// record not exist 
}
else 
//matched


我们无法执行您的为你工作.您将需要研究如何调用SQL并自己执行.
We cannot do your job for you. You will need to research how to call SQL and do this yourself.


这篇关于如何在asp.net网页中使用数据库字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆