Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.ServiceModel;
- using FirebirdSql.Data.FirebirdClient;
- using FirebirdSql.Data.Isql;
- namespace Test.Server
- {
- [ServiceContract(Namespace = "Test.Server")]
- public interface IUser
- {
- [OperationContract]
- bool AddUser(string user, string pass);
- }
- public class UserService : IUser
- {
- String constring = "server type=Embedded;User=SYSDBA;Pooling=false;Password=masterkey;Database=c:\\Chorus\\data.fdb";
- // add new user to the database
- public bool AddUser(string user, string pass)
- {
- using (FbConnection con = new FbConnection(constring))
- {
- con.Open();
- if (CheckUser(user, pass, con) == 0)
- {
- FbCommand cmd = new FbCommand("INSERT INTO users (name, pass) VALUES ('" + user + "','" + pass + "')", con);
- cmd.ExecuteNonQuery();
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- // check if user exists
- private int CheckUser(string user, string pass, FbConnection con)
- {
- // this is where the exception might be occurring.
- // if i comment out both the lines below and return a dummy value, the problem seems to go away.
- // could this have something to do with integer overflows corrupting the stack?
- FbCommand cmd = new FbCommand("SELECT count(*) FROM users WHERE name='" + user + "' AND pass='" + pass +"'", con);
- return Convert.ToInt32(cmd.ExecuteScalar());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement