Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Vb.net & SQLite

Vb.net & SQLite

Scheduled Pinned Locked Moved Visual Basic
csharpsqlitedesigntools
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Ben Magee
    wrote on last edited by
    #1

    Hi, I'm trying to design a login script using VB.net 2008 and the System.Data.SQLite wrapper. So far I have my SQLite tables setup with a default user (user: admin pass: test dob: 1990/01/01 name: John Smith) and I connect using the following code:

    Imports System.Data.SQLite

    Dim userName As String
    Dim passWord As String
    userName = usrBox.Text
    passWord = passBox.Text

    Dim sqlConnection As New SQLite.SQLiteConnection()

    Dim sqlCommand As New SQLiteCommand

    sqlConnection.ConnectionString = "Data Source=users.db3

    sqlConnection.Open()
    sqlCommand = sqlConnection.CreateCommand()
    sqlCommand.CommandText = "SELECT * FROM users WHERE username = " & userName

    However, I don't know how to check if the statement has rows for me to check if the user exists, and then I would have to do the same for passwords. Anyone know how to check if the statement has rows using a similar function? Cheers, Ben.

    S 1 Reply Last reply
    0
    • B Ben Magee

      Hi, I'm trying to design a login script using VB.net 2008 and the System.Data.SQLite wrapper. So far I have my SQLite tables setup with a default user (user: admin pass: test dob: 1990/01/01 name: John Smith) and I connect using the following code:

      Imports System.Data.SQLite

      Dim userName As String
      Dim passWord As String
      userName = usrBox.Text
      passWord = passBox.Text

      Dim sqlConnection As New SQLite.SQLiteConnection()

      Dim sqlCommand As New SQLiteCommand

      sqlConnection.ConnectionString = "Data Source=users.db3

      sqlConnection.Open()
      sqlCommand = sqlConnection.CreateCommand()
      sqlCommand.CommandText = "SELECT * FROM users WHERE username = " & userName

      However, I don't know how to check if the statement has rows for me to check if the user exists, and then I would have to do the same for passwords. Anyone know how to check if the statement has rows using a similar function? Cheers, Ben.

      S Offline
      S Offline
      Sebastian Br
      wrote on last edited by
      #2

      You could use a "SELECT COUNT(*) ..." as SQL and then add something like this to your code: Integer.Parse(sqlCommand.ExecuteScalar().ToString) Another method is to create a DataTable first (using your SQL statement above): Dim aDataTable As DataTable Dim aDbDataAdapter As DbDataAdapter sqlCommand.CommandText = sql aDbDataAdapter.SelectCommand = sqlCommand aDbDataAdapter.Fill(aDataTable) aDbDataAdapter.FillSchema(aDataTable, SchemaType.Source) aDataTable.TableName = tableName and then evaluate the Row-Count: aDataTable.Rows.Count

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups