IS this Correct or Please help me to find error, i cant solve that how to see record on my form


Dim Slec As New SqlDataAdapter

Slec.SelectCommand = New SqlCommand("SELECT Name'=" & txtname.Text & "', CNIC#='" & txtcnic.Text & "', F_Name='" & txtfname.Text & "', College='" & txtdept.Text & "', Academic_Year='" & txtacad.Text & "' where Seat#='" & txtacad.Text & "' FROM Student_BioData ", sqlconn)

sqlconn.Open()
Slec.SelectCommand.ExecuteNonQuery()
Slc.SelectCommand.ExecuteNonQuery()

sqlconn.Close()

Try
            Dim cn As SqlConnection
            Dim strCnn As String = "Your data base connection string"
            cn = New SqlConnection(strCnn)
            cn.Open()
            Dim comm As New SqlCommand("Your sp or Command text to get the data from DB", cn)
            '' If ur using Sp then Commandtype= CommandType.StoredProcedure if it   is  Text then comm.CommandType=CommandType.Text
            comm.CommandType = CommandType.StoredProcedure
            Dim da As New SqlDataAdapter(comm)
            Dim ds As New DataSet
            da.Fill(ds)
            'Ur dataset will have records
            ''Close your connections and commands.
        Catch ex As Exception
            ''Handle error if any
        End Try

Dim comm As New SqlCommand("Your sp or Command text to get the data from DB", cn)

My Dear Frnd how this line will be written ,specialy ur where u have written the string:
I want see sql data in my form : means in diffrent text boxes

strCnn is the string variable you need to pass ur database connections string.
Like

Persist Security Info=true; Data Source="Server Name";UID = "User Id";PWD="Password for DB";Initial Catalog="Default database to connect";

And then get ur data into dataset by using fill command of dataadapter. And then assign the values to text box.

My dear Friend I was talking about that bold text, and dear you had told me for making connection : Please help to solve that my dear:
Actully i was trying to select the data from sql data base and wana to show in my form that i designed... but i can't make that coz im in student level my dear:
OR give me you Id to whom i can contact or take this ID and please contact with me as soon as possible: me_hardosh@yahoo.com

Dim comm As New SqlCommand("Your sp or Command text to get the data from DB", cn)
'' If ur using Sp then Commandtype= CommandType.StoredProcedure if it is Text then comm.CommandType=CommandType.Text

I have given the complete code to get ur data from server. You just need to prepare connection string for SQL serever and Select statement. Where ur not able to understand my code?. We cannot write code for you here.

dear im not talking about to get data: i had done that, but im talking about to retrieve data OR to see the data on diffrent text boxes means if name then name wana show on Text box of name etc.... but i cant make the entire query to set that:
as we enter thequery in sql server as : SELECT FIRST_NAME, LAST_NAME FROM EMM : if i wana call that query on TEXT BOXes of VB.net like as FIRST_NAME=F/NAMe.text etc then how can i set that query on it....
im very thankfull to you my dear to giving me time....

Will your Query will return just one row? And you want assign those result set to controls on form right?

This article has been dead for over six months. Start a new discussion instead.