|
Hello Guys, Can anyone tell me the difference between ExecuteNonQuery & ExecuteScalar. Also, in what cases should one use ExecuteNonQuery & ExecuteScalar.
With Best Regards,
Mayur
|
|
|
|
|
use ExecuteScaler when u need to get only one value from DB(i.e. when u're using aggregate func) and use ExecuteNonQuery when u need to insert/update/delete operation.
e.g
if ur query is "SELECT AVG(sal) FROM MyTable"
then use ExecuteScaler, because it returns only one value.
this is not the end, this is how its goin to begin !
|
|
|
|
|
considering your eg. if i need to obtain the avg(sal) of emp from a table group by department, then will i get several records as per the departments if i use executescalar.
thnx for your reply.
With Best Regards,
Mayur
|
|
|
|
|
then u cant use ExecuteScaler in dat case. or u can use ExecuteScaler but it'll return the first value returned by SQL Query...its only for one value...
this is not the end, this is how its goin to begin !
|
|
|
|
|
ok thnx a lot. also i noticed 'ExecuteReader'. Any idea about it. Also, i need to know whether there is any way where I insert/update/delete records to the datatable and reflect all changes to the database in the end. My current operation is taking a lot of time to execute each insert/update/delete statement.
With Best Regards,
Mayur
-- modified at 4:17 Wednesday 22nd February, 2006
|
|
|
|
|
ExecuteReader used in simple database read operation to populate SQLDataReader with ur query...like
// some code
Dim dr As SQLDataReader=cmd.ExecuteReader
while( dr.Read() )
// get values using dr.GetValue(0)
End While
as of ur 2nd question, i need chk out n will post here later, becoz i forgot the code ...all i can say is updation of DB from DataTable is ALWAYS possible.
this is not the end, this is how its goin to begin !
|
|
|
|
|
Thnx a lot. I will be waiting for your reply regarding 'Database updation from datatable". Right now I am facing a lot of problem using the traditional method of updating each record since the operation involves huge data.
Once again thx for your help. Have a nice day.
With Best Regards,
Mayur
|
|
|
|
|
hi there,
is there any way to add listview to a custom treeview like a child node
when we exapnd any node in the treeview i want to add a listview as a child node
thnx in advance
nagaraju kondepudi
-- modified at 1:30 Wednesday 22nd February, 2006
|
|
|
|
|
Hi..
I have an assignment to send sms via mobile which is connected to pc...
I used API commands to send sms... but these codes disabling the ports where i connect the mobile... so can u please help me... if u have code, can u please send it to my id...? (mannu.ba@gmail.com)
Thanx
from
Manu
Manu
|
|
|
|
|
Hello,
I have a laptop that has some "special" buttons, one of which opens a programmable menu that can launch programs, opens directories, and rotates the monitor.
To make a long story short, the interface for the programmable button is a little combersome, so I thought I could do a little better. The only problem is, I'm not sure how to handle the "button press;" I'm not even sure how to detect the state or presence of the button. I do know that it does not raise the keydown, keyup, or keypress events.
Any help would be appreciated. Thanks.
|
|
|
|
|
Syberaptor,
The "Special Buttons" on your laptop are controlled by a proprietary filter drivers, they have nothing to do with the keyboard.
On an HP Laptop for instance, one of the more common driver names they use is "eawdmfd.sys", but this is by no means standard, compaq (now merged with HP) uses one called "eaps2kbd.sys". Some of them have more than just the driver they also have dependancies to dynamic link libraries like "fltrcoi.dll" for instance.
I haven't seen any "Generic" code for working with these drivers recently, but I can tell you, that it will be quite an adventure for you if you decide to dive into filter drivers and the windows ddk.
If your really interested, the first thing you should probably do is download the windows ddk,and take a look, It is part of the Kernel-Mode Driver framework found here:
http://www.microsoft.com/whdc/driver/WDF/KMDF_pkgdwn.mspx?
It has some interesting sample codes on filter drivers.
Be prepared to start programming in more than one language, and learn all you can about p/invoke in the framework if you decide to interface your work in the .net framework, and have the desire to do this type of work.
That should get you started....
Hope it helps...
progload
|
|
|
|
|
Thanks for the help.
Drivers are a little beyond me, I think. Though I may see if I can figure anything out.
Thanks again.
|
|
|
|
|
I have built the following code in my global.asax code
My question is how and when does the Sub application_start know when to start?
What must I do to trigger it to start and send an email?
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
myConnection.Open()
'2. Create the command object, for the query
Const strSQL As String = "Select LastUpdated, ProductId from products "
Dim objCmd As New SqlCommand(strSQL, myConnection)
Dim objDR As SqlDataReader
objDR = objCmd.ExecuteReader()
While (objDR.Read)
'look the code is looking for DATETIME .. but it found NULL values
'need this code to keep from getting errors if a null is found
'we need to put some check for nulls
If (Not (objDR("LastUpdated") Is DBNull.Value)) Then
If (Date.Compare(objDR("LastUpdated"), Today.Date) = 0) Then
Dim newMail As New MailMessage
newMail.From = "from@from.com" '' this is the From Address
newMail.To = "kenn_rosie@msn.com" '' this is TO Address
newMail.Subject = "Change in Product Rate"
newMail.Body = " Dear Ken, " & _
"Please review attached email for product ID: " & objDR("ProductID") & _
"Thank you," & _
"Kenn()"
End If
End If
End While
myConnection.Close() 'Close the connection
End Sub
|
|
|
|
|
It runs when your ASP.NET app spins up for the first time.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Not quite sure what that means.... example, in my code I updated a db field that was placed in a word document, then I have the sub application_start send it email.
I did that earlier today but have not received the email back yet, so I was wondering if I have to write code that causes the sub application_start to start?
|
|
|
|
|
kenn_rosie wrote: so I was wondering if I have to write code that causes the sub application_start to start?
No, but unless you restart IIS, this code won't run. It gets run when IIS starts.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hmm, so How do I get it to work to send out email without restarting IIS, That seems strange? If I want the email to go out daily, do I need to have a trigger or something to restart IIS all the time?
|
|
|
|
|
No need to restart IIS daily for purpose of sending mail .Restarting IIS means restarting application .
If you want to automatically send email daily , then create a small exe In which can be scheduled to run once in a day .This exe can be created in vb / vb.net .
Divya Rathi
|
|
|
|
|
My application is going to move some files when a button is clicked.
If the file is opened by other application,
my system.io.file.move(file) will have exception,
How can I detect the file is opened by other application before the move action?
Thanks.
|
|
|
|
|
Catch the exception.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I know this method, but any other way?
|
|
|
|
|
No.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Catching the Exception is the only way to get feedback that a file is open and can not be moved...
What you need to do is loop throuhg the files you are moving and when it hits a locked file it keeps trying till it can.
<br />
Dim bIOEx As Boolean = True<br />
Try<br />
If blnMove = True Then<br />
Do<br />
Try<br />
System.IO.File.Move(strOriginalFile, strDestinationFile)<br />
bIOEx = False<br />
<br />
Catch ex As IOException<br />
bIOEx = True<br />
End Try<br />
Loop Until bIOEx = False<br />
End If<br />
Catch ex As Exception<br />
MessageBox.Show("The File Redirection Failed" & vbCrLf & ex.Message, "Move Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)<br />
Finally<br />
blnMove = False<br />
End Try<br />
You may want to do a loop count that times out after 3 tries 10 seconds apart.
Hope this helps...
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
I am new at vb.net and would like to know
What object is streamwriter located under?
Is it a function or sub routine?
VS 2003:
I have a project with the folowing in code behind:
Dim sw As StreamWriter
I thought maybe I could drill down in the objects and find it.
I assume that is under System.IO?
I did an Ctrl ALT J in visual studio to look at the classes
and I cannot drill down to streamWriter?
Where can I find where streamwriter is located?
|
|
|
|
|