______________________________________________________________________________
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conTransit As SqlConnection = New SqlConnection("Server=devsql;Database=Transporter;Integrated Security=SSPI")
conTransit.Open()
MessageBox.Show("Conection succedded")
conTransit.Close()
End Sub
End Class
Any help or commnet is warmly welcome also how can i load the data and ADD, DELETE and DPDATE using ADO.net Help Pls
Ripal SoniPosted Mar 20, 2007, 8:19 AM
try this out i hope it will help you
if not(mycommand is nothing) then
mycommand.dispose()
mycommand=nothing
end if
GurdeepPosted Mar 13, 2007, 11:17 AM
Private Sub Custcomboitems()
Dim dc(1) As DataColumn
Dim dcCntry(1) As DataColumn
Try
If conTransit.State = ConnectionState.Closed Then
conTransit.Open()
End If
Dim myCommand As New SqlCommand("Select * From Customer order by Short_Description", conTransit)
Dim myReader As SqlDataReader
myReader = myCommand.ExecuteReader()
While myReader.Read()
daCustomer = New SqlDataAdapter(myCommand)
daCustomer.Fill(dtCustomer)
dc(0) = dtCustomer.Columns("Customer_ID")
dtCustomer.PrimaryKey = dc
cmbCustShortDesc.DataSource = dtCustomer
cmbCustShortDesc.DisplayMember = "Short_Description"
cmbCustShortDesc.ValueMember = "Customer_ID"
End While
Me.myReader.Close()
End Sub
'Where
'conTransit is SQL connection which is working fine
'cmbCustShortDesc is combo box to which data is bound
ANY HELP PLZ
Gordon AdamsPosted Mar 4, 2007, 12:03 AM
My Connection String:
"Server=ServerNameHere;uid=UserIDHere;pwd=PasswordHere;database=DataBaseNameHere;"
Only thing in code changes is your Dim statement could be written:
Dim conTransit As New SqlConnection("ConnectionStringHere")
But what you have will work, just not necessary.
Here is a great link for different connection strings:
http://www.connectionstrings.com/
Also depending on what error your getting may mean you need to have SQL Server Service Manager running.
Good Luck!