|
I am trying to display some data from a database withing a gridview. Using a few books, i have managed to display the data in a msngbox but im having problmes displaying it on the asp webpage. Heres what i have at the moment:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myconnection As OleDbConnection
myconnection = New OleDbConnection()
Dim connectionString As String = "provider=Microsoft.Jet.OLEDB.4.0;" + _
"data source = C:\Documents and Settings\admin2\My Documents\glaxodata.mdb"
myconnection.ConnectionString = connectionString
Dim mycommand As OleDbCommand
mycommand = New OleDbCommand("select * from glaxoAll5032007OrderDetail", myconnection)
Dim myreader As OleDbDataReader
myconnection.Open()
myreader = mycommand.ExecuteReader()
myreader.Read()
Dim newrow As DataRow
MsgBox(myreader("Field1"))
Dim mytable As DataTable
mytable = New DataTable()
mytable.Rows.Add(newrow)
MsgBox(mytable.Rows.Count)
mytable.Rows.Add()
GridView1.DataSource = mytable
myconnection.Close()
End Sub
can any1 help?
|
|
|
|
|
Hi!
I dint understand why you are using ExecuteReader? It returns single record right?
If you want to bind more than one record get data to datatable directly and bind to the gridview
'GridView1.DataSource = mytable' after this line add the following line
'GridView1.databind()'
|
|
|
|
|
How do I find out how many rows are retrieved using a select statement and a table adapter?
I need to use this number in a for loop.
Greg
|
|
|
|
|
If you have populated a table with your select statement then you can get a count with MyTable.Rows.Count
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
I tried using MyDataTable.Rows.Count and I get the blue line.
Does it matter if I am using typed or untyped datasets?
|
|
|
|
|
MyTable is the name of the Table object for example
Dim myDataSet as new System.Data.DataSet<br />
'Populate your dataset here<br />
<br />
Dim MyTable as System.Data.DataTable<br />
MyTable = myDataSet.Tables(0)
The Rows.Count works on both typed and untyped datatables
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
To use that code do I have to import any particular namespace?
|
|
|
|
|
I have a ListView control in a form. I want to add a "Select All" button on the form that selects all items in the ListView control. I cannot find a way to do this. The "SelectedIndices" and "SelectedItems" are readonly properties.
How do I programatically select an item in the ListView?
|
|
|
|
|
Here's how you do it:
For Each item As ListViewItem In lv.Items
item.Selected = True
Next
lv.Focus()
Note that you need need to set the focus back to the ListView control, because the items won't be highlighted when the control does not have focus (by default, lv.HideSelection = true). Instead of giving focus back to the control, you could set the lv.HideSelection to false, but the highlight will be gray instead of blue (when the control does not have focus).
|
|
|
|
|
Hello, I am working on a VB.Net application, which is called from another application and accepts commandline arguments. I want to strict users from opening multiple instances, instead I want to load existing instance and run a particular form based on the command line argument.
I will appreciate if someone help me out.
Thanks
|
|
|
|
|
This will determine whether or not your program is already running :-
Function IsAlreadyRunning() as Boolean<br />
Dim currentProcess As Process = Process.GetCurrentProcess()<br />
Dim allProcesses() As Process = Process.GetProcessesByName(currentProcess.ProcessName)<br />
<br />
If allProcesses.Length > 1 Then<br />
Return True<br />
Else<br />
Return False<br />
End If<br />
End Function
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
Many thanks for your quick reply. Can you please guide me how to load/access a running instance of application and to call a form.
Thanks
Nas
|
|
|
|
|
Not sure of that myself. I would believe the only way is to pass a message to the program somehow.
I would look into using Windows Message Queues and have your calling program send a message to before a task and your receiving program listen out for the message and act accordingly when one is received.
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
I have no idea about Message Qeue, I would be very thankful if you could spare some time and help me out.
Thanks
|
|
|
|
|
Have a look at some of the articles of CodeProject CodeProject MSMQ articles[^]
Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'
|
|
|
|
|
research mutex - several projects here that show you how....
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
|
|
|
|
|
How can i add Double Quotes ("") in VB.NET Message Box, i tried \" but its not working
For example: I want to display information as...
My name is Jats as My name "Jats"
Jats
|
|
|
|
|
try "" inside your literal string
so just a double quote would look like """"
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
"My name ""Jats"""
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Thankx Guffa, it helped.
Jats
|
|
|
|
|
Hi Friends,
I need to check the LAN connection status by using vb.net 2003(web application).
for ex:
you can assume that 10 machines are connected with each other any one of the machine is disconnected for the LAN means I have to know the status of disconnected machine status and connected machine status.
Do the needful
Thanks in Advance,
Known Is Drop.Unknown Is Ocean
|
|
|
|
|
|
I created a "UserControl" with about 260 controls, about 70% of them are UserControls with about 3 windows forms such as TextBox, ComboBox and DateTimePicker (which I will call "simple usercontrols" from now on). These 260 controls are spread over 7 TabPages of a TabControl.
From a certain point of the development on, the IDE hasn't shown the simple usercontrols any more (except for one of the tabpages in which the controls are still visible).
- The code, which is created automatically by the windows form designer seems to contain all the needed code for the controls in the same way as before, as far as I can see.
- In the form designer, the simple usercontrols are still listed in the combo within the propery window. When I select a simple usercontrol via this combo, it is marked in the form designer (surrounded by this typical rectangle telling the size of the control) though it is still invisible.
- The executable is ok, i.e. the "simple usercontrols" are visible.
To get rid of the problem I tried the following: I went back to a version of my usercontrol which didn't have this problem, added a few further controls and the same problem occured again.
Does there exist an upper limit of controls a form disgner can handle?
If someone has a hint/an idea to solve the problem, that would be really great. - Thanks in advance,
Michael
Code is in VB.Net 2003 (7.1.6030), Visual Studio 2003 with hotfix KB937059 and SP1 KB918007; MS.Net Framework 1.1 (1.1.4322 SP1)
|
|
|
|
|
i migrated the vb project into that of the .net
for the statment
Me.Cursor = vbNormal i am getting error it is not accepting vbNormal..
how to resolve it...
C:\Inetpub\wwwroot\HSBC.NET\frmApplication.vb(3324): Value of type 'Microsoft.VisualBasic.FileAttribute' cannot be converted to 'System.Windows.Forms.Cursor'.
|
|
|
|
|
soniasan wrote: Cursor
Look at the documentation for <a href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.cursor.aspx">Cursor</a>[<a href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.cursor.aspx" target="_blank" title="New Window">^</a>] . What type does it say it accepts?
|
|
|
|