You are on page 1of 1

Dim con As New SqlConnection

Dim cmd As New SqlCommand


Try
con.ConnectionString = "Data Source=atisource;Initial Catalog=BillingSys;Persist
Security Info=True;User ID=sa;Password=12345678"
con.Open()
cmd.Connection = con
cmd.CommandText = "INSERT INTO table([field1], [field2]) VALUES([Value1], [Value
2])"
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Error while inserting record on table..." & ex.Message, "Insert
Records")
Finally
con.Close()
End Try

--------------------Dim con As New SqlConnecti


Dim cmd As New SqlCommand
Try
con.ConnectionString = "Data Source=atisource;Initial Catalog=BillingSys;Persist
Security Info=True;User ID=sa;Password=12345678"
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT [field1], [field2] FROM [tablename] ORDER BY [sortfiel
d]"
Dim lrd As SqlDataReader = cmd.ExecuteReader()
While lrd.Read()
if lrd("password").Tostring()==txtpassowrd.text then
msgbox("Correct Password!")
end if
End While
Catch ex As Exception
MessageBox.Show("Error while retrieving records on table..." & ex.Message, "Load
Records")
Finally
con.Close()
End Try

textbox = lrd("field").tostring()

You might also like