Click here to Skip to main content
15,918,003 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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

VB
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
 
Share this answer
 

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