Dear all,
I have created a small vb.net program.
I need to retrive data from sql by vb.net and modify it but when I run it, it returns with the first record at sql table.
That means the query is not executed.
Can you please check this code and give me a solution
Imports System.Data.SqlClient
Imports System.Data
Imports System.IO
Public Class main
Private sqlconn As New SqlConnection("Data Source=MODY-PC;Initial Catalog=Sosa;User ID=sa;Password=password123")
Private da As New SqlDataAdapter("SELECT * from EM_TBL", sqlconn)
Private coomd As New SqlCommand("SELECT * from EM_TBL where Where EM_NAME =@ddd", sqlconn)
Private ds As New DataSet
Private cmb As New SqlCommandBuilder(da)
Private cmd As New SqlCommand
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
Login_Form.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
coomd.Parameters.AddWithValue("@ddd", TextBox1.Text)
da.Fill(ds, "EM_TBL")
TextBox3.DataBindings.Add("text", ds, "EM_TBL.EM_NAME")
TextBox2.DataBindings.Add("text", ds, "EM_TBL.EM_MID_NA")
TextBox4.DataBindings.Add("text", ds, "EM_TBL.EM_LAST")
TextBox5.DataBindings.Add("text", ds, "EM_TBL.JOP")
TextBox6.DataBindings.Add("text", ds, "EM_TBL.ID_NO")
TextBox7.DataBindings.Add("text", ds, "EM_TBL.PASS_NO")
TextBox8.DataBindings.Add("text", ds, "EM_TBL.PASS_DATE")
TextBox9.DataBindings.Add("text", ds, "EM_TBL.RES_EXP_DATE")
TextBox10.DataBindings.Add("text", ds, "EM_TBL.NATIONALITY")
TextBox11.DataBindings.Add("text", ds, "EM_TBL.MOB1")
TextBox12.DataBindings.Add("text", ds, "EM_TBL.MOB2")
TextBox13.DataBindings.Add("text", ds, "EM_TBL.HOME_NO")
TextBox14.DataBindings.Add("text", ds, "EM_TBL.ADDRESS")
TextBox15.DataBindings.Add("text", ds, "EM_TBL.COMMENT")
sqlconn.Close()
Catch ex As Exception
End Try
End Sub
[edit]Converted from "inline code" to "code block" = OriginalGriff[/edit]