Работа с базой данных H2 из C#C#

Место общения программистов C#
Ответить
Anonymous
 Работа с базой данных H2 из C#

Сообщение Anonymous »


I am able to connect to H2 database from my C# application with the help of below mentioned URL

http://www.h2database.com/html/advanced ... ft_dot_net

org.h2.Driver.load(); Connection conn = DriverManager.getConnection("jdbc:h2:~/test", "sa", "sa"); Statement stat = conn.createStatement(); //Working ResultSet rs = stat.executeQuery("SELECT 'Hello World'"); while (rs.next()) { Console.WriteLine(rs.getString(1)); } //Not Working ResultSet rs1 = stat.executeQuery("SELECT * FROM TEST"); while (rs1.next()) { Console.WriteLine(rs1.getString(1)); } I have changed the code "SELECT 'Hello World'" to "SELECT * FROM TEST" where "TEST" is the table name. I am getting table not found error. But the table is present in H2 database.

EDIT @ Nick Bull- Thank you so much for your help. Due to some reason the table created in "H2 console" is not accessible through c# code. I have tried with your logic, creating the table from C# code, it worked!!. But it is not showing in H2 console.

One more thing, "executeQuery" did not work for me to create the new table, I used "executeUpdate" (for someone it may help)


Источник: https://stackoverflow.com/questions/387 ... om-c-sharp
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»