|
I'm always trying to improve my code. In past programs, using VS 2003 when I had a windows form application with a button setup to allow the client access to a website, I would code the click event with the following:
System.Diagnostics.Process.Start("http://www.somewebsite.com")
This code works fine, but now I'm using VS 2005 and there has to be a better more efficient way of rewriting this code.
Any help is appreciated.
Lost in the vast sea of .NET
|
|
|
|
|
KreativeKai wrote: This code works fine, but now I'm using VS 2005 and there has to be a better more efficient way of rewriting this code.
Why?
Under 2005, it's exactly the same code. There is no alternative thats "better".
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I wasn't sure. I know that it used to take a long section of code to try and get the computer name and now all you need to do in VS 2005 is type my.computer.name
I wasn't sure if there was an alternative in VS 2005 to the Start code.
Thanks!
Lost in the vast sea of .NET
|
|
|
|
|
KreativeKai wrote: I know that it used to take a long section of code to try and get the computer name
Huh? What "long section of code"? In previous versions of the .NET Framework, all you had to do was use Environment.MachineName to get that.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ok, you're right... I used a bad example.
I guess my question is:
Is my.computer.name any more efficient or better to use over system.environment.machinename?
Microsoft gives you 10 different ways to do the same task, but my question is always which way is more efficient?
When they come out with a new version, I always try to use the new functionality if possible and try not to stay stuck using the same old code when there is simpler code to use.
Thanks for your help
Lost in the vast sea of .NET
|
|
|
|
|
The My namespace doesn't replace anything or make anything more efficient. All it is is a bunch of classes written as shortcuts, or pre-written code, to do common tasks.
Want to see the code behind My.Computer.Name ?
Computer is a class that appears to sit in the My namespace, but is actually under Microsoft.VisualBasic.Devices . It is a class that inherits from the ServerComputer class that sits in the same namespace. Here's the code, in partial class form:
Namespace Microsoft.VisualBasic.Devices
Public Class Computer
Inherits Microsoft.VisualBasic.Devices.ServerComputer
...
... ' more code specific to the Computer class
...
End Class
Public Class ServerComputer
Public Sub New()
End Sub
Public ReadOnly Property Name() As String
Get
Return Environment.MachineName
End Get
End Property
... ' More methods and properties for ServerComputer ...
End Class
End Namespace
The entire My namespace is stuff like this. In fact, I think the entire My namespace sits in various namespaces under the Microsoft.VisualBasic namespace.
If want to explore this stuff yourself, just Google for ".NET Reflector" and download it (it's free!). Then you can explore all the code in the .NET Framework and see how things are done!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I suspect some thing is messed up with the .NET 1.1 and so i want to reinstall that
The reason i came to that conclusion is that a .NET application i wrote previously which was working previously well is now generating an error
"Application has generated an exception that could not be handled process id = .... Thread id = .... "
The same application works perfectly on my computer and i know that it worked perfectly two days before too on one of our customer computer and some thing was done on that server afterwards.
Well i want to know if there is an easy way to remove it and reinstall it its on windows 2003 server. It does not show up in Add Remove Programs. When i just run dotnetfx.exe(redistributable package) it says its already there.
|
|
|
|
|
I am trying to use the built-in .NET Binding Navigator and am having some issues. I use a dataset for the Binding Source's Data Source and when I fire the program the icons on the navigator are disabled. The count also says only 1 when there are 3 records in the DB. This part of the project is just displaying user details that are retrieved from a Sql Server DB. Let me know if this is too general of a description.
UPDATE:
I am now having a problem connecting to the DB, getting a SQLException Unhandled : 'login failed for user (user)' . The connection string it uses is the same as another currently working DataAdapter. I can preview the data from the TableAdapter so I know the connection is working. Any ideas?
TIA
Big Pimpin, Spendin Gs
Nate Lindley, .NET Aficionado
|
|
|
|
|
I am a amateur programmer.just to jumbed into the pool only with interest.I have experience in database progrmming in mysql and vb6.I have no formal software education as I am a Government officer.
so please help
how can i connect MYSQL DATABASE TO VB.NET 2005.
I USE THE FOLLOWING CODE IN VB6
Public cnn as new ADODB.CONNECTION
Public str as string
sub main()
str= "Provider=MSDASQL.1;Persist Security Info=False;Data Source=revive"
cnn.connectionstring=str
cnn.open
This will connect mysql database to vb6
Pleae help me
with regards
JOSEPH
|
|
|
|
|
Try checking this[^] site out.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Can any body tell me how to get a server ip address in a textbox.
I have sqlserver 2000 in my lan and i am using vb.net 2003.
Please help me
|
|
|
|
|
Hi programmers,
i get the cannot connect to smtp server error when i try to send mail through mail from my vb application.
i used aspsmartmail componet for this.
the mails goes correctly when i use normal outlook express or my domain account through internet explorer but gives error when i send it through my code.
i am giving the code snippet which sends mails. sorry i cant give full details of my mail server and email account in code snippet plz consider for this.
plz help me guys.
Dim mySmartMail As aspSmartMail.SmartMail<br />
Set mySmartMail = New aspSmartMail.SmartMail<br />
<br />
mySmartMail.Server = "ip address of mail server"<br />
mySmartMail.ServerTimeOut = 35<br />
mySmartMail.UserName = "username"<br />
mySmartMail.Password = "password"<br />
<br />
mySmartMail.SenderAddress = "test@mydomain.com" <br />
<br />
<br />
mySmartMail.Recipients.Add "nitin@mydomain.com"<br />
<br />
mySmartMail.Subject = "my mail"<br />
mySmartMail.Body = "body"<br />
<br />
mySmartMail.SendMail<br />
<br />
Set mySmartMail = Nothing<br />
<br />
Help!
Nitin...
|
|
|
|
|
Well, you'll most likely have to get with the people that wrote that component. If you purchased it, then you have at least 1 FREE support incident, otherwise it's $159/incident.
If the IP works in Outlook, the exact same server name/IP should work in this component. If it's not, there might be some setting in this component that you have to set, but have so far failed to do so. I have no idea what that would be, since I've never used this component.
Another possibility is that you have the free version and it expires. If so, then you'll have to shovel out the money to get the full version.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
With VS2003 in a webapplication.
I want to have a messagebox to pop up when a user fills data into a textbox and this data is invalid. spesifically : there is a field for filling in a price, I have a function that makes sure that the data is valid and in range. But I want to inform the user that the data is invalid. If tried using the msgbox(...) function but I take it that it cant be used in a webpage, in that way.
Is there a way to do this?
|
|
|
|
|
Hi,
u ll have to use Javascript alert functiom
hope this works.
Nitin...
|
|
|
|
|
Ok then if i may ask how do you call a javascript function (alert) from within VB code.???
|
|
|
|
|
hi,
Response.Write("<script lang=""javascript"">alert('Nitin')</script>")
hope this works
Nitin..
|
|
|
|
|
You really should use registerclientscriptblock to insert jscript. If I get you right, you're saying do a postback, if the values are outside the range, insert the script so that the posted back page shows a popup message ? It would be easier to use validation controls that generate teh script and run without postback.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thank you very much!!! It works!!!!
Just one last question? I know I'm becoming annoying - hehe
Is there a way to preserve the items in the background?
My app is fairly mature so I hay have inadvertently changed something that cases this phenomenon
The MSGBOX displays but there is a completely blank page behind it until you click ok at which stage it returns to normal.
Thanx once again
|
|
|
|
|
What you want to do is use a validation control, this can generate the javascript to check the values on the client, and pop up a message box. You need to also check on the server, if there's a chance your client page could be hacked.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
in my vb.net project
i have a requirement to open a word file which contain formated text ,tables,images
i can open it in a rich text box or pannel or in any way but the area allocated to me half the screen onely
i dont know how to open it in
vb.net
can any one help me
mail me at rajesh.batchu@cesltd.com
|
|
|
|
|
hi,
I want to know if there is a way to change the type of a Column in DatagridView at run time. And if so, how?
Thanks in advance
|
|
|
|
|
Once the column is created, you cannot change it's type. You have to remove the column(s), then create your own and add them to the Columns collection. It would probably be a good idea to create your own columns for each column you want to display:
Private Sub SetupDGVAndBind()
DataGridView1.Columns.Clear()
Dim col As New DataGridViewTextBoxColumn
col.HeaderText = "headerText"
col.DataPropertyName = "columnName in table"
DataGridView1.Columns.Add(col)
DataGridView1.DataSource = myBindingSource
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
I have some (more than once) COM-Servers (in different DLL's) and each of them implements the same Interface. Only what I know is the InterfaceName and the ProgID of the COM-Server.
How can I instanciate a COM-Object in VB.NET with this informations? I C/C++ it looks like:
HRESULT hr = CLSIDFromProgID (ProgID), &clsid);
hr = CoCreateInstance (clsid, NULL, CLSCTX_INPROC_SERVER, IID_IInterfaceName, (void **) &m_pCOMSmartPtr);
\\\| \\ - -
( @ @ )
+---------------oOOo-(_)-oOOo-----------------+
| Stephan Pilz stephan.pilz@stephan-pilz.de |
| <a href=www.stephan-pilz.de>www.stephan-pilz.de</a> |
| ICQ#: 127823481 |
+-----------------------Oooo------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
|
|
|
|
|
Does something like this work for you?
Dim t As Type = Type.GetTypeFromProgID("progID")
Dim retVal As Object
retVal = Activator.CreateInstance(t)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|