Click here to Skip to main content
15,905,071 members
Home / Discussions / Database
   

Database

 
AnswerRe: Get Just The Latest Pin
Chris Meech23-Feb-12 4:35
Chris Meech23-Feb-12 4:35 
GeneralRe: Get Just The Latest Pin
GenJerDan23-Feb-12 4:45
GenJerDan23-Feb-12 4:45 
GeneralRe: Get Just The Latest Pin
Chris Meech23-Feb-12 4:48
Chris Meech23-Feb-12 4:48 
GeneralRe: Get Just The Latest Pin
GenJerDan23-Feb-12 9:45
GenJerDan23-Feb-12 9:45 
AnswerRe: Get Just The Latest Pin
David Mujica23-Feb-12 5:15
David Mujica23-Feb-12 5:15 
QuestionOrder of tables in an Inner Join Pin
dbrenth22-Feb-12 3:25
dbrenth22-Feb-12 3:25 
AnswerRe: Order of tables in an Inner Join Pin
Shameel22-Feb-12 3:36
professionalShameel22-Feb-12 3:36 
Questiontrouble in connecting to Postgre SQL from web server. Pin
hellono121-Feb-12 20:43
hellono121-Feb-12 20:43 
Hi all.
I'm now developing a website that connect to Postgre SQL database. I used NpgSQL.DLL to connect from C# to database. I also finished testing this project in my local pc, it worked well. But unfortunately it did not work well in server. Some errors in connecting to server happened.
These errors happened when website had much people logged in and began using database query functions ( select, update, delete .. ). I think errors begin from codes in connect database functions. but i still can not fix it. this is my connecting database codes.
------ codes connects database ---------
C#
--  Connect.cs file.
public static void connectDB()
    {
        try
        {
                conn.ConnectionString = connection;
                conn.Open();
        }
        catch
        {
            //closeConnectDB();
        }
    }
    public static void closeConnectDB()
    {
        //conn.Dispose();
            conn.Close();
        //conn.Dispose();
    }
    public static int ExecuteQuery(string SQL)
    {
        try
        {
            connectDB();
            NpgsqlCommand cmd = new NpgsqlCommand(SQL, conn);
            return cmd.ExecuteNonQuery();
        }
        catch
        {
            closeConnectDB();
            return 0;
        }
        
    }

    public static DataSet SelectQuery(string SQL)
    {
        DataSet ds = new DataSet();
        try
        {
            connectDB();
            NpgsqlDataAdapter nDa = new NpgsqlDataAdapter(SQL, conn);
            
            nDa.Fill(ds);
            // closeConnectDB();
            return ds;
        }
        catch
        {
            closeConnectDB();
            return ds;
        }
        
    }


----------------- use to execute these codes --------

....

C#
--- calling functions files.
try
                        {
                            string strTest = "Select * from abc where .. ";
                            DataSet ds1 = new DataSet();
                            ds1 = Connect.SelectQuery(strTest);
                            if (ds1.Tables[0].Rows.Count > 0)
                            {
                                
                            }
                            else
                            {
                                int kq = Connect.ExecuteQuery(strInsert);
                                if (kq > 0)
                                {
                                    int kk = Connect.ExecuteQuery(strUpdate);
                                    kk = Connect.ExecuteQuery(strUpdate2);
                                    
                                    strHTML = "OK";
                                }
                            }
                        }
                        catch
                        {
                            strHTML = "errors.";
                        }
                        finally
                        {
                            int kk = Connect.ExecuteQuery(strUpdate);
                            kk = Connect.ExecuteQuery(strUpdate2);
                           
                            strHTML += "-- Sub Finally";
                        }


-----------------End calling function---------------
Here sometimes it worked well but sometimes catched errors.
Can you help me? thanks and regards.
AnswerRe: trouble in connecting to Postgre SQL from web server. Pin
Pete O'Hanlon22-Feb-12 2:50
mvePete O'Hanlon22-Feb-12 2:50 
GeneralRe: trouble in connecting to Postgre SQL from web server. Pin
hellono122-Feb-12 4:05
hellono122-Feb-12 4:05 
AnswerRe: trouble in connecting to Postgre SQL from web server. Pin
Luc Pattyn22-Feb-12 2:56
sitebuilderLuc Pattyn22-Feb-12 2:56 
GeneralRe: trouble in connecting to Postgre SQL from web server. Pin
hellono122-Feb-12 4:06
hellono122-Feb-12 4:06 
Questiondesign a database Pin
messages19-Feb-12 5:06
messages19-Feb-12 5:06 
AnswerRe: design a database Pin
Eddy Vluggen19-Feb-12 5:39
professionalEddy Vluggen19-Feb-12 5:39 
GeneralRe: design a database Pin
Hamid_RT19-Feb-12 5:53
Hamid_RT19-Feb-12 5:53 
AnswerRe: design a database Pin
Eddy Vluggen19-Feb-12 6:09
professionalEddy Vluggen19-Feb-12 6:09 
AnswerRe: design a database Pin
Luc Pattyn19-Feb-12 6:55
sitebuilderLuc Pattyn19-Feb-12 6:55 
GeneralRe: design a database Pin
messages19-Feb-12 17:22
messages19-Feb-12 17:22 
AnswerRe: design a database Pin
Mycroft Holmes19-Feb-12 12:08
professionalMycroft Holmes19-Feb-12 12:08 
GeneralRe: design a database Pin
messages19-Feb-12 17:21
messages19-Feb-12 17:21 
GeneralRe: design a database Pin
Mycroft Holmes19-Feb-12 17:27
professionalMycroft Holmes19-Feb-12 17:27 
GeneralRe: design a database Pin
messages19-Feb-12 19:40
messages19-Feb-12 19:40 
GeneralRe: design a database Pin
Mycroft Holmes19-Feb-12 20:03
professionalMycroft Holmes19-Feb-12 20:03 
GeneralRe: design a database Pin
messages20-Feb-12 0:54
messages20-Feb-12 0:54 
GeneralRe: design a database Pin
Jörgen Andersson20-Feb-12 3:02
professionalJörgen Andersson20-Feb-12 3:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.