Hi Guys,
I am having a major problem connecting a carrying out commands on my SQL Server. I can connect and do commands fine using Microsoft SQL Server Management Studio (I login using Windows authentication). I have a connection string my project settings and whenever I test the connection it says "test connection succeeded" On the SQL Server Configuration I have the "Log on as:" set to "Local System" could this be a problem? Do I need to download any plug-ins or anything? Also in SQL Server Configuration I have both the SQL Server Agent (SQLSERVER) and SQL Server Browser stopped but the SQL Server (SQLSERVER) Running, could this be the cause of the issue?
This is my VB code:
I can't think of anything else you may need to know, but if there let me know and I will try my best to answer! Any suggestions are welcome and thank you in advance.
Ryan
I am having a major problem connecting a carrying out commands on my SQL Server. I can connect and do commands fine using Microsoft SQL Server Management Studio (I login using Windows authentication). I have a connection string my project settings and whenever I test the connection it says "test connection succeeded" On the SQL Server Configuration I have the "Log on as:" set to "Local System" could this be a problem? Do I need to download any plug-ins or anything? Also in SQL Server Configuration I have both the SQL Server Agent (SQLSERVER) and SQL Server Browser stopped but the SQL Server (SQLSERVER) Running, could this be the cause of the issue?
This is my VB code:
Code:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
Dim Connection As New SqlConnection
Dim Command As New SqlCommand
Try
Connection.ConnectionString = "Data Source=RYAN\SQLSERVER;Initial Catalog=Test;Integrated Security=True"
Connection.Open()
Command.CommandText = "INSERT INTO Users(Firstname, Surname)" & vbNewLine & "VALUES('" & txtFirstname.Text & "', " & txtSurname.Text & "')"
Command.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Error! - " & ex.Message)
Finally
Connection.Close()
End Try
End Sub
End Class
Ryan