|
I fetch a record from databse using SQL query. The result is in my command object. But i don't know that how to retrieve the values from command objects and how to iterate through it. Can any one help me ?
Dim rs As Data.SqlClient.SqlCommand = New Data.SqlClient.SqlCommand("select * from customer")
SQLREADER = rs.ExecuteReader
rs.ExecuteNonQuery()
Imtiaz
Imtiaz
|
|
|
|
|
From the code you have given the result will not be in the Command Object as there are no output parameters.
Second, the rs.ExecuteNonQuery() won't do anything useful because your SQL is a SELECT statement. ExecuteNonQuery is for when you do not expect any results back.
Your results are in the SqlDataReader object. Use the SqlDataReader.Read()[^] method to extract each record. The return value of this method will be true if a record was read, or false if there are no more records.
The data reader holds tha values of the current record, it has a number of Get...[^] methods to assist you in getting the values for each of the fields.
After you have the values you need for a record, loop around again calling the Read method until you have all your data.
Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Try this if you want a data reader:
<br />
Dim cnn as SqlConnection = New Connection(connectionString)<br />
Dim cmd as SqlCommand = New SqlCommand("SELECT * FROM Customer", cnn)<br />
Dim rdr as SqlDataReader = cmd.ExecuteReader()<br />
<br />
'Now iterate through the reader<br />
While rdr.Read()<br />
Console.WriteLine(rdr("CustomerName"))<br />
End While<br />
...<br />
Dan Morris
|
|
|
|
|
Hello I am building an application for work and they are running windows 98 and when I run the unfinished application on the computer it crashes it. The computer appears to run out of resources. But on my windows xp laptop I can run multiples of the program and not crash it. Does the file system matter NTFS or FAT?
|
|
|
|
|
Normally, no. But that and what's causing it to crash depends on what your app is doing and with what resources.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
it's not a file system metter ur did code the wrong event may be when the form activate of another check it out
Imtiaz
|
|
|
|
|
In my opinion, it is not relatet to the file system (FAT or NTFS). I used to use windows 98 and found it is very difficult when it have a problem. Its always display kernel error when there is lack of the memory resource. While windows 2000 and windows xp, change the style to manage error handling in windows environment. It seem that most of application could run very stable whether its have some error occure.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Win 98 has a very limited amount of GDI resources, which can cause this sort of problem.
1) On XP, open the task manager
2) Choose View/Select Columns...
3) Check the GDI Objects checkbox
4) Monitor this value in the listview as you use the application.
If it continues to rise, without ever dropping, then you probably have some sort of resource leak in your app. If it is just very high, the app will probably crash on Win 98.
my blog
|
|
|
|
|
Thank you for you help. The GDI object on my app went up to 128 max, and now has settled as 126. Well now all can do is take this information to my boss as see what he has to say about upgrading.
|
|
|
|
|
The filesystem is irrelevant. do you write this program in visual basic .net or with common visual basic ? if your write with .net then check whether .net framework is still installed. if your wirte in common visual basic check your ocx or activeX files or check they are correctly registered.
Thomas Wilkop
|
|
|
|
|
Being written in visual basic .net the framework is fine because I have the same problem on two different computers running 98. But the one computer running 2000 can handle the program just fine.
If I break up the GUI in to more then one form it does work in 98 just looks like crap.
Thanks for the help
Dale Burmeister
|
|
|
|
|
is it possible to add a total field in one column of the datagrid which caluculates the total price of a product.
say, if one field has price one field has quantity (editable) the total should be display on the total column as soon as the focus from the quantity is gone.
thanks for ur time
srikanth
|
|
|
|
|
How to sum the fields in a Windows Forms DataGrid control and then display the calculated totals in a footer by using Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;EN-US;836672
|
|
|
|
|
thank u for ur suggestion ........
i am looking for having total field not only at the footer but on each and every row
|
|
|
|
|
summers over school is in, yet again.
heh, well, for the past 5 months or so on my school vacation, i hadnt used VB.net. now im lost again :S
first off: im not asking you to do my homework, im asking for help..
my project is as follows: two text boxes, and one button. i need to write a program to find the difference (number of days) between 2 entered days (ex, day1 = monday, day2= friday, difference = 4 days.
i have an enum like this:
Private Enum DaysOfWeek
Monday = 1
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
End Enum
i also have 2 variables that i made of the enum type (startDay and endDay). i set startDay and endDay's value = their respective textboxes.text, which the user enters a day of week. i get cast from string to integer error (i know, because enums must only be integer values, right?)
so how can i do this? (sorry if being broad, again, im not asking you to do my homework for me, im asking for help.)
thank you
------------------------
Jordan.
III
|
|
|
|
|
Instead of casting string to enum use the Enum.Parse method to convert the string to Enum.
|
|
|
|
|
im off to bed, but, i WILL definetly check it out. iv never heard of that method before, ill look into it!
thank you very much!
------------------------
Jordan.
III
|
|
|
|
|
Hello everybody. I am new to VB.NET and i have the following code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objPrint As New System.Drawing.Printing.PrinterSettings
Dim strItem As String
Dim strPrinters As String
For Each strItem In objPrint.InstalledPrinters
cmbPrinter.Items.Add(strPrinters & strItem)
Next
End Sub
I am able to get all the list of available printers and i want when i click on one of them a list to be filled with all available paper sizes for that printer. So far no luck. Can anyone help me. Thank you in advance...
Trying to find the way
|
|
|
|
|
.NET Framework Class Library
PrinterSettings.PaperSizes Property
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawingprintingprintersettingsclasspapersizestopic.asp
|
|
|
|
|
Thank you Anonymous. It has all the information needed. But still I can't seem to be able to make the paper size combobox to get the papers sizes of the printer that i have clicked on the printer combobox. I can only seem to be able to get the default's one. ARGGG!!! What am i doing wrong?
HEEEEELPPPPP
Trying to find the way
|
|
|
|
|
Without seeing your code, it's impossible to tell you. PaperSizes returns a collection. Are you enumerating the collection it returns or just using the first item from it?
We need to see the code...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok here is the code so far:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objPrint As New System.Drawing.Printing.PrinterSettings
Dim strItem As String
Dim strPrinters As String
For Each strItem In objPrint.InstalledPrinters
cmbPrinter.Items.Add(strPrinters & strItem)
Next
End Sub
Private Sub cmbPrinter_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPrinter.SelectedIndexChanged
' Add list of supported paper sizes found on the printer.
Dim searchstring As String
Dim SearchChar As String
Dim MyPos As Integer
Dim i As Integer
Dim pkSize As System.Drawing.Printing.PaperSize = Nothing
SearchChar = "A4"
For Each pkSize In printDoc.PrinterSettings.PaperSizes
lstPaper.Items.Add(pkSize.PaperName)
Next
For i = 0 To lstPaper.Items.Count - 1
lstPaper.SelectedIndex = i
searchstring = lstPaper.SelectedItem()
MyPos = InStr(searchstring, SearchChar)
If MyPos = 0 Then
lstPaper.Items.Remove(0)
Else
paperToUse = searchstring
End If
Next
updateDisplay()
End Sub
I can fill the combobox of the printers and the list box of the papers. BUT when i click on another printer the program DOSEN'T give me the list of the paper sizes on the new selected printer. It's like it stucks in the paper sizes of the default printer...
HEEEEEEEEEEEEEEEEEEEEEEEEEELP!!!
Trying to find the way
|
|
|
|
|
I was able to load the datagrid correctly and fill it. What I am trying now to accomplish is how to highlight a whole row when I user either tabs down or clicks the row. As of now it highlights just one column of the row. I want to be able to highlight the whole row and have a user click the row to get the info the user is requesting.
Thanks
Beginner in ASP.Net and VB.Net
|
|
|
|
|
.NET Framework Class Library
DataGrid.Select Method (Int32)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsDataGridClassSelectTopic1.asp
|
|
|
|
|
That is the right track but if a user clicks on (row 1 column 3) then all the data for (row 1 column 1) and (row 1 column 2) disappears and the whole row is highlighted. I have seen this done in programs so I know its possible.
Right now my rows alternate colors with light blue and baby blue. When a user selects a row they want to view, then I want to highlight that row to stand out like with a yellow or even a darker blue to make it look different from the rest.
Thanks
Beginner in ASP.Net and VB.Net
|
|
|
|