You can try this code:-
SqlCommand comm = new SqlCommand("SELECT Usuario, Senha from Membros WHERE
Usuario =...@usuario And sen...@senha", conn);

conn.Open();
  comm.Parameters.Add("@Usuario",SqlDbType.VarChar).Value = uidtxt.Text;
  comm.Parameters.Add("@Senha", SqlDbType.VarChar).Value = psstxt.Text;


  MessageBox.Show("Conexão Aberta");
 SqlDataReader rd = comm.ExecuteReader();

  if (rd.Read())
{

  MessageBox.Show("Abrindo Servidor");
}
  else

{
MessageBox.Show("Usuário ou Senha Incorreto, tembém verifique sua conexão
com a internet");
}

  conn.Close();



                                    Ranveer Shekhawat
On Wed, Aug 19, 2009 at 1:20 AM, Paulo Hendler <[email protected]>wrote:

> Hello people
>
> In first thank's a lot
> for the help....
>
> My SQL scrypt error was an horror huhauhua OK , I Did again as follows:
>
>
>
> SqlCommand comm = new SqlCommand("SELECT Usuario, Senha from Membros WHERE
> Usuario ='@Usuario' And <='@Usuario'%20And> Senha='@Senha'", conn);
>             comm.Parameters.Add("@Usuario",SqlDbType.VarChar).Value =
> uidtxt.Text;
>            comm.Parameters.Add("@Senha", SqlDbType.VarChar).Value =
> psstxt.Text;
>
>           conn.Open();
>           MessageBox.Show("Conexão Aberta");
>           int i =  (int) comm.ExecuteScalar(); *Error here again*
>            if (i<0)
>                MessageBox.Show("Abrindo Servidor");
>             else
>                 MessageBox.Show("Usuário ou Senha Incorreto, tembém
> verifique sua conexão com a internet");
>
>
>                     conn.Close();
>
>
> And there's an error:
>
>
> System.NullReferenceException was unhandled
>   Message="Obejct Reference not defined for an object instance."
>   Source="Agrarion"
>   StackTrace:
>        em Agrarion.Form1.logbtn_Click(Object sender, EventArgs e) na
> F:\Agrarion\Agrarion\Agrarion\Form1.cs:linha 77
>        em System.Windows.Forms.Control.OnClick(EventArgs e)
>        em System.Windows.Forms.Button.OnClick(EventArgs e)
>        em System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
>        em System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
> button, Int32 clicks)
>        em System.Windows.Forms.Control.WndProc(Message& m)
>        em System.Windows.Forms.ButtonBase.WndProc(Message& m)
>        em System.Windows.Forms.Button.WndProc(Message& m)
>        em
> System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
>        em System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
> m)
>        em System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
> Int32 msg, IntPtr wparam, IntPtr lparam)
>        em System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
> msg)
>        em
> System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
> dwComponentID, Int32 reason, Int32 pvLoopData)
>        em
> System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
> reason, ApplicationContext context)
>        em
> System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
> ApplicationContext context)
>        em System.Windows.Forms.Application.Run(Form mainForm)
>        em Agrarion.Program.Main() na
> F:\Agrarion\Agrarion\Agrarion\Program.cs:linha 17
>        em System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
> args)
>        em System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
> assemblySecurity, String[] args)
>        em Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
>        em System.Threading.ThreadHelper.ThreadStart_Context(Object state)
>        em System.Threading.ExecutionContext.Run(ExecutionContext
> executionContext, ContextCallback callback, Object state)
>        em System.Threading.ThreadHelper.ThreadStart()
>
> The first error ocurred on the not convert text to VCHAR and I did the
> modification , and after it!
>
> Does anyone explain it to me
>
> Thank's
>
>
>
>
>
> 2009/8/18 Arjun Priyananth <[email protected]>
>
>> Correct the select statement. "Select user from Membros"  ... or "Select
>> *** from  Membros"
>>
>>  SqlCommand comm = new SqlCommand ("SELECT  from Membros WHERE User =
>> '@User' And Password='@Password'",conn <Password='@Password'%22,conn>);
>>
>>
>>
>>
>>
>>
>>  On Tue, Aug 18, 2009 at 8:21 AM, Paulo Hendler 
>> <[email protected]>wrote:
>>
>>> Hello Guys...
>>>
>>>
>>> I'm trying to do a Login Area form after splash form (C# windows forms
>>> aplication), and a table named Membros
>>> where are the colummns User, Password in a web SQL Server to run the
>>> client access.
>>> But I've an error near keyword "From". Follow the code:
>>>
>>>
>>> using System;
>>> using System.Collections.Generic;
>>> using System.ComponentModel;
>>> using System.Data;
>>> using System.Data.SqlTypes;
>>> using System.Data.SqlClient;
>>> using System.Drawing;
>>> using System.Text;
>>> using System.Windows.Forms;
>>> using System.Threading;
>>>
>>>
>>>
>>> private void logbtn_Click(object sender, EventArgs e)
>>>         {
>>>
>>>            SqlConnection conn = new SqlConnection (@"Data Source=
>>> theserver.com\sqlexpress;Persist Security Info=True;User
>>> ID=UIS;Password=xxxxxx");
>>>            SqlCommand comm = new SqlCommand ("SELECT from Membros WHERE
>>> User = '@User' And Password='@Password'",conn<Password='@Password'%22,conn>
>>> );
>>>
>>>                     comm.Parameters.Add("@*...@user'*",SqlDbType.Text).Value
>>> = uidtxt.Text;
>>>                     comm.Parameters.Add(''*...@password'* <''@Password'>",
>>> SqlDbType.Text).Value = psstxt.Text;
>>>                     conn.Open();
>>>                     MessageBox.Show("Conection Open");
>>>
>>>
>>>             *int i = (int) comm.ExecuteScalar(); --> Here lives the
>>> error !*
>>>
>>>
>>>                if (i<0)
>>>                      MessageBox.Show("Conection Open test 2");
>>>                else
>>>                      MessageBox.Show("Usuário ou Senha Incorreto, tembém
>>> verifique sua conexão com a internet");
>>>                      conn.Close();
>>>
>>>
>>>
>>>
>>> And the Error:
>>> sqlexception was unhandled
>>>
>>> *Incorrect syntax near the keyword 'from'.*
>>>
>>>
>>> *I don't know what's bad done, and if anyone know other way to do it
>>> I'm ready to try, or to set this code right!*
>>> *HUAhuh*
>>>
>>>
>>> *Thank's for now*
>>>
>>>
>>>
>>>
>>
>>
>

Reply via email to