try this:
Code: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 conn As New SqlConnection("connection string") Dim cmd As New SqlCommand("SELECT [Name] FROM employee WHERE employeeID=@employeeID", conn) 'which of these 2 parameters you use depends on employeeID field datatype cmd.Parameters.Add("@employeeID", SqlDbType.Int).Value = CInt(textbox1.text) 'cmd.Parameters.Add("@employeeID", SqlDbType.VarChar).Value = textbox1.text Dim o As Object = cmd.ExecuteScalar TextBox2.text = If(o IsNot Nothing, o.ToString, "") End Sub End Class




Reply With Quote