Hi, I have many questions regarding SQL databases. I'm very new to this subject and I need to know how to upload (or create) a database on a server and where I can find the connection string. First of all, a database on a server can be accessed with any program with the correct connection string, right? Also, does it update in real-time? (I'm thinking of using Azure but I don't know the quality of the free trial.) And this is some example code I made to manage tables in a local database. Is there anything wrong with it or anything I may need to add? Like I said, I'm new to this and don't really know where to begin. Thanks in advance!
~Nic

vb Code:
  1. Imports System.Data.SqlClient
  2. Public Class Form1
  3.  
  4.     Dim connString As String = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=""MY_LOCAL_FILE_PATH\Database1.mdf"";Integrated Security=True"
  5.     Dim myConnection As SqlConnection = New SqlConnection(connString)
  6.     Dim dr As SqlDataReader
  7.  
  8.     Private Sub CreateTable(TName As String)
  9.         myConnection.Open()
  10.         Dim command As String = $"
  11. IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='{TName}' AND xtype='U')
  12.     CREATE TABLE [dbo].[{TName}]
  13.     (
  14.         intRecID Int IDENTITY(1,1) NOT NULL PRIMARY KEY,
  15.         FirstName VARCHAR(50) NOT NULL,
  16.         LastName VARCHAR(50) NOT NULL,
  17.         Email VARCHAR(50) NULL,
  18.         Create_Date Smalldatetime DEFAULT GETDATE()
  19.     )"
  20.         Dim cmd As SqlCommand = New SqlCommand(command, myConnection)
  21.         cmd.ExecuteNonQuery()
  22.         myConnection.Close()
  23.     End Sub
  24.  
  25.     Private Sub AddEntry(TName As String, FName As String, LName As String, Email As String)
  26.         myConnection.Open()
  27.         Dim command As String = $"INSERT INTO {TName} (FirstName, LastName, Email) VALUES ('{FName}', '{LName}', '{Email}')"
  28.         Dim cmd As SqlCommand = New SqlCommand(command, myConnection)
  29.         cmd.ExecuteNonQuery()
  30.         myConnection.Close()
  31.     End Sub
  32.  
  33.     Private Function GetEntry(TName As String, Column As String, ColumnValue As String, ColumnNeeded As String) As String
  34.         myConnection.Open()
  35.         Dim command As String = $"SELECT {ColumnNeeded} FROM {TName} WHERE ({Column} = '{ColumnValue}')"
  36.         Dim cmd As SqlCommand = New SqlCommand(command, myConnection)
  37.         dr = cmd.ExecuteReader
  38.         Dim str As String = ""
  39.         While dr.Read
  40.             str += dr(0).ToString
  41.         End While
  42.         myConnection.Close()
  43.         Return str
  44.     End Function
  45.  
  46.     Private Sub ClearTable(TName As String)
  47.         myConnection.Open()
  48.         Dim command As String = $"DELETE FROM {TName}"
  49.         Dim cmd As SqlCommand = New SqlCommand(command, myConnection)
  50.         cmd.ExecuteNonQuery()
  51.         myConnection.Close()
  52.     End Sub
  53.  
  54.     Private Sub DeleteTable(TName As String)
  55.         myConnection.Open()
  56.         Dim command As String = $"DROP TABLE {TName}"
  57.         Dim cmd As SqlCommand = New SqlCommand(command, myConnection)
  58.         cmd.ExecuteNonQuery()
  59.         myConnection.Close()
  60.     End Sub
  61.  
  62.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  63.  
  64.         CreateTable("T1")
  65.         ClearTable("T1")
  66.         AddEntry("T1", "Dave", "Johnson", "[email protected]")
  67.  
  68.         MsgBox(GetEntry("T1", "FirstName", "Dave", "Email")) ' This retrieves Dave's email address.
  69.  
  70.     End Sub
  71.  
  72. End Class