|
How do I run a SQL stored procedure from within Visual Basic?
Thank you.
|
|
|
|
|
|
the very simple method is use the procedure as you use the select query
cmd.CommandType = "ProcedureName p1,p2,p3"
' Either
cmd.executenonquery
'or if you want to recieve some thing
da.SelectCommand = cmd
da.Fill(Dt)
where cmd= Command
da= dataadapter
dt=datatable
p1,p2,p3 are the parameters which you need to send
hope this will help
|
|
|
|
|
|
hi i am a student working on my final year project i hav dissabled print option from the file menu using a com addin but when i press ctrl + P the print option comes up again. some one help me
and i want only my addin to work in word i want to dissable all other addins can some one guide me
chandrashekar
|
|
|
|
|
Maybe Dave can double check me but if you assign the key sequence to something else like form1.focus then it might bypass the print function.
1. Out of clutter, find simplicity.
2. From discord, find harmony.
3. In the middle of difficulty lies opportunity.
Albert Einstein
three rules of work
|
|
|
|
|
Sorry, I don't do Office automation.
But, it doesn't sound like the right idea.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hello, is there anyone know how to auto-fill a textbox?
I have 4 textbox, first_name, middle_name, last_name, and full_name, I want the full_name textbox to be auto-filled when the first_name, middle_name, and last_name entered, so user doesn't need to fill in the full_name textbox. any idea to do this?
thanks.
Lisa
|
|
|
|
|
Handle the TextChanged events of the 3 text boxes, you could even do this with a single function. Combine the contents of the 3 text boxes and place the result in the FullName textbox.
Private Sub NameTextBoxesChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FirstName.TextChanged, MiddleName.TextChanged, LastName.TextChanged
FullName.Text = LastName.Text & ", " & FirstName.Text & " " & MiddleName.Text
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In VB.Net this should work (code is untested):
<br />
Private Sub Textbox_TextChanged(Sender as Object, e as EventArgs) Handles first_name.TextChanged, middle_name.TextChanged, last_name.TextChanged<br />
<br />
full_name.Text = first_name.Text & " " & middle_name.Text & " " & last_name.Text<br />
<br />
End Sub<br />
|
|
|
|
|
Ummm... and this is different from what I posted, how?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
:-OSomehow I missed your post. Sorry about that.
|
|
|
|
|
I've been trying to attach a SQlReader and SQLCommand to the same SQLConnection and i am getting the error that SqlConnection is already open.
I think that we can attach only one object to the connection at a time, correct me if i am wrong.
|
|
|
|
|
Nope, you're right. You can only attach one object to the connection at a time. But there is nothing stopping you from creating a second connection to the same database and using that with your other object.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
But then is'nt it utilising extra resources. What is connection pooling for then? I don't understand why we can only attach one object with a connection. Then it means that if i have to query the same table again using a different object(SQLReader) then for that i have to open a new connection, despite of the fact that a connection is already open on that database, putting extra load on sql server(it dosen't sound much of an issue when we are using in a simple data application, but it is a big issue with a erp model based application).
I am using vb 2005 beta. don't u think that in the next version they should allow multiple objects on sqlconnection or am i wrong?
|
|
|
|
|
Connection pooling is for recycling connection objects very rapdily. For example, when hundreds or thousands of users are hitting your data-driven web page, the connection objects are constantly being recycled in the pool, each making a single call to the database.
I don't know the reason behind why you can only attach one reader to a connection, maybe it's because of something to do with server-side cursors, who knows. But, best practice, unless absolutely necessary, is to open a connection, use it for whatever query you need, then close it and detroy the objects. This applies even if you have to open a new connection for a second simultaneous query.
You're really not putting that much of an extra load on the server. Going back to the website example, if connection pooling can open and close connections at a rate of thousands per second, how much of a load are you really puting on the server by opening a second connection in your application?
But, leaving a connection open DOES consume resources on the server. How many users are going to be hitting the database all at once? How much RAM is in the SQL server? How many connection licenses does your server have? Starting to get the picture?
And no, I don't think they should implement this feature to allow multiple command objects access to the same connection object. I think it'll promote bad practices, like people opening a global connection for the life of an application, which is a very bad idea!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi,
How can you close a form form within another one.
|
|
|
|
|
You can only do this if the current form has a reference to the form you want to close. If that's the case, all you have to do is call its Close() method.
What exactly are you trying to do with this?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have one main form and then a settings form. When i change the settings i need to close the main form as the settings won't take effect till i restart the program. How to I create a reference to the form i want to close
|
|
|
|
|
it depends on the scenrio you are using. like if setting form is the dialog form then on completion it will go to your main form and you can check the settings changed or not. If it is not the dialog then pass the main form reference to child form and on changing close the form by using this reference.
|
|
|
|
|
I've been writing code for 27 years and I can't follow what you just wrote.
There is no need to pass a reference to anything or have a child form or whatever... It's simple. The Settings form deal with only changing the settings, it should do anything else. Let the main form worry about restarting the app, not some child form that shouldn't be worried about such things.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Let me simplify that a little bit... Your Settings form should deal with just that, changing the settings. It shouldn't have anything to do with restarting your application.
Your Main Form should launch the Settings Form as a Dialog (.ShowDialog). When the Settings Form is done saving any changes, it should set a flag exposed as Public in the Settings Form. When closed, control will return back to the Main Form immediately after the .ShowDialog statement. This is where you check that public property on the Settings Form (it's been closed, not removed from memory!) to see if you should restart your application or not. This is where you can launch another copy of your application and quit the current one.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How to print the current form or a particular file by browsing the window simply by clicking on the button
|
|
|
|
|
You'r going to have to supply ALOT more detail than this. Printing the current form is no big deal, but what's with the "particular file by browsing the window simply by clicking on the button"? What are you talking about here.
Code: Printing a Windows Form (Visual Basic)[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|