For the very first time I am using a SQL file that is not actualy from the server. I am using a local sql datbase. I have added the connection string to my app.config file but now I am not sure how to use it in code
my config string is named MateCare
VB Code:
Private Sub AddPatient() Dim con As String = ConfigurationSettings.AppSettings("MateCare") Dim strSp As String = "InsertPatient" Dim cn As SqlConnection = New SqlConnection Dim cmd As SqlCommand = New SqlCommand(strSp, cn) cn.ConnectionString = con Try cn.Open() With cmd .CommandType = CommandType.StoredProcedure .Parameters.Add("PatientID", _ SqlDbType.Int).Direction = ParameterDirection.Input .Parameters("PatientID").Value = txtPatientID.Text End With Catch ex As Exception MessageBox.Show(ex.Message & vbNewLine & _ ex.Source, "ExecuteStartStop Dates", MessageBoxButtons.OK) End Try End Sub




Reply With Quote