Hi Kartikey...
first : i wanna say welcome in dani web...
second : you didn't show any effort from your program..
"We only give homework help to those who show effort" :)
so, when you post thread again please show the effort...effort can make all of people here to understand the problem. thx :P...
if u want to insert or update you must to connect vb.net with sql server 2000.
for better (my opinion) u can use module so u can call every time in all form..
this code for connection module :
Imports System.Data
Imports System.Data.SqlClient ' this is very important code that u must added
Module Connect
Public conn As SqlConnection
Public Function GetConnect()
conn = New SqlConnection("Server = YourServerName;" & "initial Catalog = YourDatabaseName;" & " Trusted_Connection=yes")
Return conn
End Function
End Module
this following code to insert data in database :
Dim check As Integer
Dim conn As SqlConnection
Dim cmdMedical As New SqlCommand
Dim cmdMedical1 As New SqlCommand
Dim daMedical As New SqlDataAdapter
Dim dsMedical As New DataSet
Dim dtMedical As New DataTable
Try
conn = GetConnect() ' this when u call the module to connected....
conn.Open()
cmdMedical = conn.CreateCommand
cmdMedical.CommandText = "SELECT * FROM Medical WHERE Medical_No='" & Trim(txtMedical_No.SelectedItem) & " ' "
daMedical.SelectCommand = cmdMedical
daMedical.Fill(dsMedical, "Medical")
dtMedical = dsMedical.Tables("Medical")
If (dtMedical.Rows.Count > 0) Then
MsgBox("Patient With Medical_No " & Trim(txtMedical_No.Text) & " has been added in data base", MsgBoxStyle.OKOnly, "Message :") …