Ajuda SQL
11/12/2008
0
to tentando fazer um select retornar o valor de uma coluna da tabela mas n ta dando certo
to usando c# express e sql server 2008 express
to usando c# express e sql server 2008 express
public string validaLogin(string login, string senha) { SqlConnection conexao = new SqlConnection("Data Source=.\\SQLSERVER;AttachDbFilename=\"C:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLSERVER\\MSSQL\\DATA\\ProjetoGerenciador.mdf\";Integrated Security=True;Connect Timeout=30;User Instance=True"); SqlCommand sql = new SqlCommand("Select nome from Usuario where login = \´" + login + "\´ and senha = \´" + senha + "\´;", conexao); SqlDataReader dr = null; try { conexao.Open(); dr = sql.ExecuteReader(); if (dr.HasRows) { return dr.GetString(3); } else { return ""; } } catch (Exception e) { return ""; } finally { conexao.Close(); dr.Close(); } }
Brunoalisson
Curtir tópico
+ 0
Responder
Posts
Clique aqui para fazer login e interagir na Comunidade :)