Imports System.Data.SqlClient
Public Class frmIpAddress
Dim ipcon As New SqlConnection
Dim ipcmd As New SqlCommand
Dim ipdr As SqlDataReader
Private Sub frmIpAddress_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim constring2 As String = "Data Source=HPMINI110\SQLEXPRESS;Initial Catalog=EDPC_DB;" & _
" User=sa;Password=12321;Integrated Security=false"
ipcon.ConnectionString = constring2
ipcon.Open()
ipcmd.Connection = ipcon
ipcmd.CommandText = "select * from LAN where ID=1"
ipdr = ipcmd.ExecuteReader
While ipdr.Read() 'While Data is Present
TextBox1.Text = ipdr("IpAddress").ToString
End While
ipdr.Close()
ipcon.Close()
End Sub
Retrieve records SQL w/ VB.net
Page 1 of 113 Replies - 1768 Views - Last Post: 12 January 2012 - 01:30 AM
#1
Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 08:04 PM
Replies To: Retrieve records SQL w/ VB.net
#2
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 08:10 PM
Why not just have one datagrid and be done with it?
You would have to use the me.controls(<string name of control>) - cast as a text box - to do this.. that would require making the string name of up your textboxes.. probably combining "Textbox" with a value you would increment.
#3
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 08:25 PM
You could have a For Loop to go throughout the fields in the database, look through the control collection and cast each result as a TextBox, then set the value of its Text property?
If not, please clarify.
#4
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 08:30 PM
This post has been edited by mpe-IT: 11 January 2012 - 08:34 PM
#5
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 08:37 PM
Interesting reading:
http://msdn.microsof...y/5z06z1kb.aspx
#6
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 08:41 PM
#7
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 09:02 PM
In reality, I see a horrible design what you have used!!! you have 40 records(and in db when we say record we mean db rows), I dont know how many fields your table have!!!!! How are you going to present these data!!! And what if a new record is added to your table? are you going to create another textbox?
Realy think of changing your design and use datagrid view, it is there to help table presentation for you instead of having textboxes equal to number of records you have?
A side question: Are you going to put every row in one text box?
#8
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 09:04 PM
#9
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 09:07 PM
EDIT: fixed italics tags. They don't end with [/il]!
This post has been edited by jimmyBo: 11 January 2012 - 09:09 PM
#10
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 09:09 PM
#11
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 09:11 PM
#12
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 09:16 PM
#13
Re: Retrieve records SQL w/ VB.net
Posted 11 January 2012 - 09:50 PM
#14
Re: Retrieve records SQL w/ VB.net
Posted 12 January 2012 - 01:30 AM
|
|

New Topic/Question
Reply



MultiQuote








|