Connect to SQL Server

I want to connet SQL Server in locahhost

Page 1 of 1

3 Replies - 4376 Views - Last Post: 24 October 2009 - 08:50 PM Rate Topic: -----

#1 rayeestp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 24-October 09

Connect to SQL Server

Post icon  Posted 24 October 2009 - 02:12 AM

Hi,

I am a beginner in vb.net. I have installed Visual studio 2005 along with Sql Server coming in the same DVD. I can't connect to Sql server from vb.net as local host. Can you give basic connection procedures to connect with Sql server.

Thanking you
Rayees

Is This A Good Question/Topic? 0
  • +

Replies To: Connect to SQL Server

#2 sharpy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 36
  • View blog
  • Posts: 394
  • Joined: 02-June 07

Re: Connect to SQL Server

Posted 24 October 2009 - 03:25 AM

Hi

You can connect to SQL server through the visual studio interface by adding a data source to your project, you can also create your database with the visual studio interface.

See this

http://www.dreaminco...wtopic74598.htm

You can also create an SQL database then hard code your project with SQL queries to access the tables in your database of which there are loads of examples in the snippets and tutorial sections here. Get something going then if you have any problems post your code and the errors you are getting and the guys here will be glad to help.

Hope this helps
Was This Post Helpful? 0
  • +
  • -

#3 kamran85  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-September 09

Re: Connect to SQL Server

Posted 24 October 2009 - 08:18 AM

I always use this

Dim connection As New SqlClient.SqlConnection(Data Source=Myserver;Initial Catalog=Mydatabase;Integrated Security=True)
Dim command As New SqlCommand
command.Connection = connection
command.Connection.Open()
command.CommandTimeout = 1000000
Was This Post Helpful? 0
  • +
  • -

#4 .:Rain.Disaster:.  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-July 09

Re: Connect to SQL Server

Posted 24 October 2009 - 08:50 PM

I used MySQL for my SQL server and used db4free.net For my database. Here is the register form to register for a Database its easy and quick and FREE here it is db4free Register form

Also here are some vids from a GREAT friend of mine
Visual Basic Login Using a Database
Visual Basic MySQL Login

Here is my source code of what I used.

If You Need Any Help PM Me Or Add Me Rain.Disaster@hotmail.com


Dim MySqlConnection As MySqlConnection

MySqlConnection = New MySqlConnection()
MySqlConnection.ConnectionString = "server=db4free.net;Port=3306; user id=your user ID; password=Your Pass; database=Your Database;"
								MySqlConnection.Open()

								Dim myadapter As New MySqlDataAdapter
								Dim sqlquary = "SELECT * FROM Users WHERE Username = '" & TextBox1.Text & "' AND Password = '" & TextBox2.Text & "';"
								Dim command As New MySqlCommand
								command.Connection = MySqlConnection
								command.CommandText = sqlquary
								myadapter.SelectCommand = command
								Dim mydata As MySqlDataReader
								mydata = command.ExecuteReader()

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1