0

I'll make this as simple as possible. In MySQL it is like this:

string name = myReader.Getstring("student_name");

how to do this in SQLite? Still in c#. Any help will be appreciated. Thanks in advance.

Joseph Reyes
  • 69
  • 1
  • 3
  • 10
  • What have you tried? It's pretty much the same: `var value = reader.GetString("student_name")`. Check out documentation for [GetString()](https://www.devart.com/dotconnect/sqlite/docs/Devart.Data~Devart.Common.DbDataReaderBase~GetString(String).html) and [Getting started with SQLite in C#](http://blog.tigrangasparian.com/2012/02/09/getting-started-with-sqlite-in-c-part-one/). – Serge Feb 23 '17 at 06:01
  • I tried sir. But the getstring in SQLite requires an integer as parameter not string. – Joseph Reyes Feb 23 '17 at 06:19
  • 2
    Not according to [GetString()](https://www.devart.com/dotconnect/sqlite/docs/Devart.Data~Devart.Common.DbDataReaderBase~GetString.html) documentation. However, if this is the case, you can use `reader.GetString(reader.GetOrdinal("columnName"))`. See documentation for [GetOrdinal()](https://www.devart.com/dotconnect/sqlite/docs/Devart.Data.SQLite~Devart.Data.SQLite.SQLiteDataReader~GetOrdinal.html). – Serge Feb 23 '17 at 06:22
  • Works. Thanks Very much! – Joseph Reyes Feb 23 '17 at 06:30

1 Answers1

0
string name = myReader.GetString(0);

Just do make sure that at the top of your code, before the connection, you have "string (name for your string) = "select name from (table name)";"