DB connection for vb.net form

Plz help me for Sql server 2005 connection to vb.net form

Page 1 of 1

2 Replies - 19667 Views - Last Post: 23 December 2008 - 02:41 PM Rate Topic: -----

#1 tvsprasad   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-December 08

DB connection for vb.net form

Post icon  Posted 22 December 2008 - 07:44 AM

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Text
Imports System.Windows.Forms
Imports System.Data.SqlClient

Public Class DIR
	Inherits System.Windows.Forms.Form

	Public Sub New()
		' This call is required by the Windows Form Designer.

		' Add any initialization after the InitializeComponent() call.

	End Sub

	Private Sub DIR_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

		Dim conn As New SqlClient.SqlConnection("Server=(PROG11); uid = sa; pwd= mdoffice2002; DataBase=mdoffice;" & "Integrated Security=SSPI")
		Dim rdrQuery As String = "SELECT * FROM C4DIR"
			Dim cmd As New SqlClient.SqlCommand(rdrQuery, conn)
			Dim rdr As SqlClient.SqlDataReader = cmd.ExecuteReader()
			While rdr.Read()
				PatientLN.Text() = rdr("SECAPI1LASTNAME").ToString()
			End While
		Catch ex As Exception
		End Try
	End Sub
	Public Overloads Sub Dispose()
	End Sub
End Class

Is This A Good Question/Topic? 0
  • +

Replies To: DB connection for vb.net form

#2 dklingman   User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: DB connection for vb.net form

Posted 23 December 2008 - 02:21 PM

i'd like to help you but you really aren't providing a lot of details as to what problem you are having.
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: DB connection for vb.net form

Posted 23 December 2008 - 02:41 PM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:

  • Post the code you're having problems with (DONE)
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1