title: Read from a visual basic api an SQL Server stored procedure
body: <p>Can someone point me in the right direction? I have not been able to find documentation to help me build a vb api that can read from a SQL Server stored procedure. I currently have an api that works, I was able to test my controller and the methods (GET, POST, ) work. Please let me know how can I read from a <code>.sql</code> file.</p>
  
  <p>The code below is in Calendar Model - Calendar.vb</p>
  
  <pre><code>Imports System.Data.SqlClient
  Imports System.IO
  
  Public Class Form1
  
      Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
          Dim sqlFile As String = "C:\temp\test.sql"
          Dim sqlText = File.ReadAllText(sqlFile)
          Dim connStr = "Server=.\SQLEXPRESS; Database=testing; Integrated Security=SSPI"
          Dim conn = New SqlConnection(connStr)
  
          Dim sqlCmd = New SqlCommand(sqlText, conn)
  
          Try
              conn.Open()
              sqlCmd.ExecuteNonQuery()
          Catch ex As Exception
              MsgBox("Something went wrong: " &amp; ex.Message)
          Finally
              If conn.State = ConnectionState.Open Then
                  conn.Close()
              End If
          End Try
  
      End Sub
  End Class
  </code></pre>