Hi all,
I'm trying to connect to an SQL database from my vb.net form, but getting an
error message. The code I used is the following:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ConnectSQL.Click
Dim myConnection As SqlClient.SqlConnection
myConnection.ConnectionString = "Persist Security
Info=true;Integrated Security=false;User
ID=sa;Password=xxxxx;database=yyy;server=zzzzz\mmm mm"
myConnection.Open()
End Sub
What am I missing?
--
TS 8 2861
What error message are you getting? Did you try making the connection in
Server Explorer?
Chris
"TS" <TS@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com... Hi all,
I'm trying to connect to an SQL database from my vb.net form, but getting an error message. The code I used is the following:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ConnectSQL.Click Dim myConnection As SqlClient.SqlConnection myConnection.ConnectionString = "Persist Security Info=true;Integrated Security=false;User ID=sa;Password=xxxxx;database=yyy;server=zzzzz\mmm mm" myConnection.Open() End Sub
What am I missing?
-- TS
"TS" <TS@discussions.microsoft.com> schrieb: I'm trying to connect to an SQL database from my vb.net form, but getting an error message. The code I used is the following:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ConnectSQL.Click Dim myConnection As SqlClient.SqlConnection myConnection.ConnectionString = "Persist Security Info=true;Integrated Security=false;User ID=sa;Password=xxxxx;database=yyy;server=zzzzz\mmm mm" myConnection.Open() End Sub
For possible connection strings, see
<URL:http://www.connectionstrings.com/>. What error message are you
getting?
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
You need to instantiate your connection as a 'New SQLClient.SQLConnection'.
Dim myConnection As SqlClient.SqlConnection = New SqlClient.SqlConnection
You should use a 'Try Catch' to trap your errors. You would have received
the
error:
'Object reference not set to an instance of an object.'
M. Miller
"TS" <TS@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com... Hi all,
I'm trying to connect to an SQL database from my vb.net form, but getting
an error message. The code I used is the following:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ConnectSQL.Click Dim myConnection As SqlClient.SqlConnection myConnection.ConnectionString = "Persist Security Info=true;Integrated Security=false;User ID=sa;Password=xxxxx;database=yyy;server=zzzzz\mmm mm" myConnection.Open() End Sub
What am I missing?
-- TS
Example:
Dim strConnectionString As String =
"server=(local);database=pubs;Trusted_Connection=y es"
chanmm
"TS" <TS@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com... Hi all,
I'm trying to connect to an SQL database from my vb.net form, but getting an error message. The code I used is the following:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ConnectSQL.Click Dim myConnection As SqlClient.SqlConnection myConnection.ConnectionString = "Persist Security Info=true;Integrated Security=false;User ID=sa;Password=xxxxx;database=yyy;server=zzzzz\mmm mm" myConnection.Open() End Sub
What am I missing?
-- TS
TS,
Because there are more answers, have a look at the answer from Marc, the
others two can nock at there head when they see what they wrote while it was
so easy. (Not that it is important they both give mostly great answers and I
make those mistakes as well.)
:-)
Cor
Chris,
Thanks for your reply. I coudn't establish the connection from Server
Explorer because I have vb.net standard edition
"Chris, Master of All Things Insignifican" wrote: What error message are you getting? Did you try making the connection in Server Explorer?
Chris
"TS" <TS@discussions.microsoft.com> wrote in message news:6D**********************************@microsof t.com... Hi all,
I'm trying to connect to an SQL database from my vb.net form, but getting an error message. The code I used is the following:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ConnectSQL.Click Dim myConnection As SqlClient.SqlConnection myConnection.ConnectionString = "Persist Security Info=true;Integrated Security=false;User ID=sa;Password=xxxxx;database=yyy;server=zzzzz\mmm mm" myConnection.Open() End Sub
What am I missing?
-- TS
Marc,
Thanks a lot. I tried the code you suggested and it worked fine.
"Marc Miller" wrote: You need to instantiate your connection as a 'New SQLClient.SQLConnection'.
Dim myConnection As SqlClient.SqlConnection = New SqlClient.SqlConnection
You should use a 'Try Catch' to trap your errors. You would have received the error: 'Object reference not set to an instance of an object.' M. Miller "TS" <TS@discussions.microsoft.com> wrote in message news:6D**********************************@microsof t.com... Hi all,
I'm trying to connect to an SQL database from my vb.net form, but getting an error message. The code I used is the following:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ConnectSQL.Click Dim myConnection As SqlClient.SqlConnection myConnection.ConnectionString = "Persist Security Info=true;Integrated Security=false;User ID=sa;Password=xxxxx;database=yyy;server=zzzzz\mmm mm" myConnection.Open() End Sub
What am I missing?
-- TS
Thanks for your reply. I tried what Marc suggested and it worked fine.
"Herfried K. Wagner [MVP]" wrote: "TS" <TS@discussions.microsoft.com> schrieb: I'm trying to connect to an SQL database from my vb.net form, but getting an error message. The code I used is the following:
Private Sub ConnectSQL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ConnectSQL.Click Dim myConnection As SqlClient.SqlConnection myConnection.ConnectionString = "Persist Security Info=true;Integrated Security=false;User ID=sa;Password=xxxxx;database=yyy;server=zzzzz\mmm mm" myConnection.Open() End Sub
For possible connection strings, see <URL:http://www.connectionstrings.com/>. What error message are you getting?
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jerry Orr |
last post by:
We are trying to determine the easiest (and cheapest) way to get
connections for about 50 Win2K workstations on our LAN to DB2 on a
z/OS server.
We could install DB2 Connect Personal Edition on...
|
by: Scott Holland |
last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also
AS/400 from NT Server
-- I am experienced in ORACLE and a novice at DB2. What tools would
be the equivalent of Net*8 or...
|
by: Zorba.GR |
last post by:
IBM DB2 Connect Enterprise Edition v8.2, other IBM DB2 (32 bit, 64
bit) (MULTiOS, Windows, Linux, Solaris), IBM iSoft Commerce Suite
Server Enterprise v3.2.01, IBM Tivoli Storage Resource Manager...
|
by: mayamorning123 |
last post by:
A comparison among six VSS remote tools including SourceOffSite ,
SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET
To view the full article, please visit...
|
by: DaTurk |
last post by:
I am makeing a Multicast server client setup and was wondering what the
difference is between Socket.Connect, and Socket.Bind.
It may be a stupid question, but I was just curious. Because I...
|
by: Clodoaldo Pinto |
last post by:
Can't connect to postgresql server
php error log message:
PHP Warning: pg_connect() : Unable to connect
to PostgreSQL server: could not connect to server: Permission
denied\n\tIs the server...
|
by: Marcus |
last post by:
I have a function that simply returns TRUE if it can connect to a
particular Sql Server 2005 express, or FALSE if it cannot. I am getting
some strange error codes returned when the computer that...
|
by: tamayi |
last post by:
I have a problem (like most others posting issues on this forum :) )
I have a remote server running Windows XP SP2, with both SQL Server
2005 Express with Advanced Features and SQL 2000...
|
by: RN1 |
last post by:
Is it possible to connect to my local SQL Server 2005 database from a
remote web server? If yes, what ConnectionString do I use?
Thanks,
Ron
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |