[RESOLVED] vb net 2010 how to read a single string from a sqlite3 database file
After looking everywhere i always come up with the same problem, or its in the wrong programming language or its a broken link.
so i turn to here hoping someone can help me a little bit.
what i try to do is the following.
1. open a local sqlite3 database only for reading
2. read a specific string in a table called "parts", in the colum named "name" find the value "scaff101" and the get the value of that record in the colum "quan"
Code:
(little example of the table to be more clear)
##################################################
# Parts #
##################################################
# key # Name # Type # Length # Width # Quan #
##################################################
# 1 # scaff99 # b1 # 100 # 50 # 30 #
##################################################
# 2 # scaff100 # f3 # 250 # 10 # 80 #
##################################################
# 3 # scaff101 # h9 # 125 # 25 # 90 # <-------------
##################################################
# 4 # scaff102 # z7 # 550 # 20 # 60 #
##################################################
the only part of this table i'm intrested in is "90" so i dont need anything like writing, changing, deleting, or whatever.
i'm happy if somebody can show me in the right direction or a little example code to get me started.
i have the "sqlite-netFx40-setup-bundle-x86-2010-1.0.92.0" installed to have access to the system.data.sqlite.dll and system.data.sqlite.linq.dll
but on sqlite website i could not find any usefull starting information for a beginner with databasesand i really dont need that much i think :)
thank you for your time
Re: vb net 2010 how to read a single string from a sqlite3 database file
Never used SQLite but I think the command structure is standard. If that is the case you just need a simple Select statement and ExecuteScalar
The statement should be something like:
Code:
SELECT Quan FROM name WHERE type='scaff101'
Part of the code
Code:
Dim quantity as integer
Dim conn As New SqliteConnection("Data Source=c:\mydb.db;Version=3;")
conn.Open()
Using cmd As New SqliteCommand("SELECT Quan FROM name WHERE type='scaff101'", conn)
quantity = cmd.ExecuteScalar
End Using
Re: vb net 2010 how to read a single string from a sqlite3 database file
Your SQL statement would look something like this:
Code:
"SELECT Quan FROM tablenamehere WHERE Name = 'scaff101'"
Or are you looking for the complete code of writing your specific Command and getting a result back into a DataReader and getting the value from it? I hope this will point you into the right direction and you can attempt something and let us know what happened...
Re: vb net 2010 how to read a single string from a sqlite3 database file
I think you misread the OP's statement. The table is named "name" and the column is "type", the correct statement would be
Code:
SELECT Quan FROM name WHERE type = 'scaff101'
He does not need a dataReader, he just needs that one value
Re: vb net 2010 how to read a single string from a sqlite3 database file
Thank you very much it works excatly as i wanted and needed.
and i want to set a mistake straight. the table name was "parts" i made a typo there.
when i have time i go deeper in db programming but for now this is what i was searching for.
thanks again.