如何查看我的变量是否与我的数据库兼容? [英] How can i see if my variables are compatible with my data base?

查看:88
本文介绍了如何查看我的变量是否与我的数据库兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想知道是否有人可以解释我如何才能看到我的变量是否与我的数据库兼容,在这种情况下我有这个:(bll.xpto.user)



尝试
BLL.xpto.Confiruser(txt_user.Text)

如果不是BLL.xpto.Confiruser(txt_user.Text)则没有
msgbox =成功
结束如果

//例证
//如果我插入textuser.text =QWERTY(qwerty存在于我的数据库中) )然后
//存在的前卫回报。
//如果我插入textboxuser.text =ASD(我的数据库中不存在),那么
//编程。返回完全相同的东西

如果BLL.xpto.Confiruser(txt_user.Text)<> text_user.text然后

//我不能这样,因为它有一个参数 - >puser


Catch ex作为例外
// msg错误
结束尝试





对于你们中的一些人来说,很容易理解这个问题并获得解决方案,但对我来说,很难找到解决方案。

如果你帮助我,我会很感激。



最好的问候,

Nillo123。

解决方案

Hi


您可以使用 SqlDataReader 读取()方法,如果此方法可以读取重新校正使用 selcet 查询将返回 True else False



 尝试 
BLL.xpto.Confiruser(txt_user .Text)

如果 BLL.xpto.Confiruser(txt_user.Text ) 没什么 然后
msgbox = 成功
结束 if

SqlDataReader slqdr =
// exemple
// 如果我插入 in a textuser.text = QWERTY(qwerty存在我的数据库中的class =code-keyword> 然后
// prog 返回存在。
// 如果我在
中插入 ASD(没有' t存在于我的数据库中)然后
//编程。 return 完全相同的事情

如果 BLL.xpto.Confiruser(txt_user。文本)LT;> text_user.text 然后

System.Data.SqlClient.SqlDataReader sqldr = new System.Data.SqlClient.SqlDataReader();
System.Data.SqlClient.SqlCommand sqlcom = new System.Data.SqlClient.SqlCommand( 从MyTable中选择*其中name = N' + text_user.text + ',sqldbconnection);
sqldr = sqlcom.ExecuteReader();
return sqldr.Read();

Catch ex As 例外
// msg 错误
结束 尝试


Hello I was wondering if anyone could explain me how can i see if my variables are compatible with my data base, in this case i have this : (bll.xpto.user)

try
 BLL.xpto.Confiruser(txt_user.Text)
  
     If Not BLL.xpto.Confiruser(txt_user.Text) Is Nothing Then
       msgbox = "Successful" 
end if 

     //exemple 
     // if i insert in a textuser.text="QWERTY"(qwerty exist in my database)then
     // the prog return that exist.
      // if i insert in a textboxuser.text= "ASD" (doesn't exist in my databse) then
      // the prog. return the exact same thing 

  If  BLL.xpto.Confiruser(txt_user.Text)<> text_user.text  Then

    // I can not right this way, because it has got a "parameter"-->"puser"
   

Catch ex As Exception
//msg error
end try 



For some of you it is easy to understand the problem and get the solution, but for me it's hard to find the solution.
If you help me,I will appreciate.

With best regards,
Nillo123.

解决方案

Hi
You can use SqlDataReader Read() method if this method can read reacord with your selcet query will be return True else False.

try
 BLL.xpto.Confiruser(txt_user.Text)

     If Not BLL.xpto.Confiruser(txt_user.Text) Is Nothing Then
       msgbox = "Successful"
end if

SqlDataReader slqdr = 
     //exemple
     // if i insert in a textuser.text="QWERTY"(qwerty exist in my database)then
     // the prog return that exist.
      // if i insert in a textboxuser.text= "ASD" (doesn't exist in my databse) then
      // the prog. return the exact same thing

  If  BLL.xpto.Confiruser(txt_user.Text)<> text_user.text  Then

System.Data.SqlClient.SqlDataReader sqldr = new System.Data.SqlClient.SqlDataReader();
                System.Data.SqlClient.SqlCommand sqlcom = new System.Data.SqlClient.SqlCommand("select * from MyTable where name=N'"+text_user.text+"'", sqldbconnection);
                sqldr = sqlcom.ExecuteReader();
                return sqldr.Read();

Catch ex As Exception
//msg error
end try


这篇关于如何查看我的变量是否与我的数据库兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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