Hi I'm connecting to postgres database and transfer data to my local machine.
here is my code :
public DataTable GetDataTable(string sql)
{
var conn = GetOpenConnection();
var dt = new DataTable();
var cmd = conn.CreateCommand();
cmd.CommandText = sql;
NpgsqlDataReader dr = null;
try
{
dr = cmd.ExecuteReader();
dt.Load(dr);
}
catch (Exception ex)
{
Log.Info(ex);
throw;
}
finally
{
dr.Close();
conn.Close();
}
return dt;
}
Below scenarios working fine
sql = "SELECT * FROM test_db"
sql= "SELECT * FROM testdb"
But if; sql = "SELECT * FROM testDb" then I got exception
Error 42P01 "testdb" does not exist
I notice that several tables. If I used camelcase data tables name every time it throws an exception. Here is the code which I got my exception
dr = cmd.ExecuteReader();
So I would like to know can't I call camelCase tables? What is the best solution fro this ?
appreciate your feedback and answers !! Thank you