I've managed to put together some code to retrieve data from a sql file. I plan to connect to a sql server that are operated by a database program, that update the registry every 10 sec.
Before I try to connect my program to the sql database, I need to know if my program will prohibit other progrograms to read and write to the database.
Anyone see any problems?
My program:
Imports System.Data.SqlClient
Public Class Form1
Dim SQLRead As SqlDataReader
Dim connStr As String = "Server=.\SQLExpress;AttachDbFileName=C:\tmp\DB\MyDB.mdf;integrated security=true;database=MyDB"
Dim sqlcon As New SqlConnection(connStr)
Dim QueryString As String
Private Sub Parts()
QueryString = "SELECT DATE, PCRID, STAT, PROVNR, CODE FROM dbo.PARTS"
Dim PartsCmd As New SqlCommand(QueryString, sqlcon)
sqlcon.Open()
SQLRead = PartsCmd.ExecuteReader()
While SQLRead.Read()
'Some Code
End While
SQLRead.Close()
sqlcon.Close()
End Sub
Private Sub Prov()
QueryString = "SELECT LOT, ART, ANATYPE, RUN, PROVNR dbo.PROV"
Dim ProvCmd As New SqlCommand(QueryString, sqlcon)
sqlcon.Open()
SQLRead = ProvCmd.ExecuteReader()
While SQLRead.Read()
'Some Code
End While
SQLRead.Close()
sqlcon.Close()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class