|
Its Done,
Thanks for Help
I need a to send string and retreive string to sql table using sql command. I write:
sqlcomm = new sqlcomman (insert into mytable (name) values ('string'),sqlconn)
Bu How can i do this using a textbox, I miss understand the syntax.
Thanks
|
|
|
|
|
I used DirectSound to record voice from microphone and the variable is set up as:
Dim voiceBuffer() As Byte
As the voiceBuffer is in byte format, I cannot play the voice using DirectSound through speakers.
Does anyone know how to create a stream and use it to play the DirectSound buffer?
Thank you.
Best Regards,
whineygrace
|
|
|
|
|
Hi guys!
need some help from u guys..
i m developing an application which retrieves MAC address from the provided IP addresses on LAN i tried using
SendARP class in which DAVE KRESKOWIAK Help me a lot
the code i used is
<dllimport("iphlpapi.dll")> _
Private Shared Function SendARP(ByVal DestIP As Integer, ByVal SrcIP As Integer, <out()> ByVal pMacAddr() As Byte, ByRef PhyAddrLen As Integer) As Integer
End Function
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
Try
Dim addr As IPAddress = IPAddress.Parse(TextBox5.Text)
Dim mac(6) As Byte
Dim len As Integer = mac.Length
SendARP(CInt(addr.Address), 0, mac, len)
Dim macAddress As String = BitConverter.ToString(mac, 0, len)
' MsgBox(macAddress)
If macAddress = "" Then
MsgBox("enter proper IPAddress")
Return
End If
TextBox6.Text = macAddress
Catch ex As System.FormatException
MsgBox("Enter an Valid IP Address...", MsgBoxStyle.Critical)
Catch ex As System.ArithmeticException
MsgBox("Cannot extract MAC address of the given IP Address as it is not a Windows OS.. ", MsgBoxStyle.Critical)
End Try
end sub
But the problem is that it only retrieves the MAC address of Windows Operating System Not any other OS like Linux Solorois. Some of our system are these only
it throghs an Arithmetic over Flow Exception.
can any one help me out in retreiving the other OS MAC address.
abhinav
|
|
|
|
|
abhinish wrote: ut the problem is that it only retrieves the MAC address of Windows Operating System Not any other OS like Linux Solorois. Some of our system are these only
it throghs an Arithmetic over Flow Exception.
can any one help me out in retreiving the other OS MAC address
The MAC address if physically hard coded in the NIC (Network Interface Card), unique for each one of them, and is not OS dependant.
|
|
|
|
|
OK. Well, I tried your code and found a problem with the data types your using to pass the Source and Destination IP's to SendARP. Your using Integer, which are signed 32-bit numbers. The sign limits the numbers range from -2147483648 to 2147483647. A signed Integer reserves the first bit for the sign, leaving the remaining 31 bits for the number.
Why is this important? Because when you convert an IpAddress (essentially 4 8-bit numbers) to an Integer (32-bits long), part of the address of the first byte ends up in the sign bit of a signed Integer. When the IpAddress object returns its integer version of the address it holds, it's returning a signed Long, or 64-bit number. This number can exceed the max value a SIGNED Integer can hold! But, it won't exceed the max value an UNSIGNED Integer can, which is 4294967295. When you convert that value to a signed Integer, the sign bit is retained, reguardless of the value that was in that bit when the number was converted to a 32-bit value. This little conversion gotcha changes the address your trying to resolve the MAC for! When you convert the 64-bit signed integer down to a 32-bit unsigned value, the sign bit is dropped since it isn't used in the new data type.
After changing the parameters you're using in your SendARP call, it works great!
[might help if I pasted in the code correctly...]
Imports System.Net
Public Class IpHelpers
Declare Auto Function SendARP Lib "iphlpapi" ( _
ByVal DestIp As UInteger, _
ByVal SrcIp As UInteger, _
ByVal MacBytes() As Byte, _
ByVal PhysAddrLength As Integer _
) As Integer
Public Shared Function GetMacAsStringFromIp(ByVal TargetIp As IPAddress) As String
Dim rc As Integer
Dim MacBytes(6) As Byte
Dim Length As Integer = MacBytes.Length
Try
Dim Ip32 As UInteger = CType(TargetIp.Address, UInteger)
rc = SendARP(Ip32, 0, MacBytes, Length)
Catch ex As Exception
' This is usefull for catching any .NET Exceptions thrown because of coding problems.
MsgBox(ex.Message)
End Try
If rc <> 0 Then
' SendARP will fail with error 31 if the Target IPAddress doesn't respond.
' This can happen if the IP really doesn't exist, isn't on the local subnet
' or if the conversion of the IPAddress to a number that SendARP expects
' isn't done properly.
Throw New ArgumentException(String.Format("Win32 Error {0} returned by SendARP!", rc))
End If
Return String.Format("{0:X2}:{1:X2}:{2:X2}:{3:X2}:{4:X2}:{5:X2}", _
MacBytes(0), MacBytes(1), MacBytes(2), _
MacBytes(3), MacBytes(4), MacBytes(5))
End Function
End Class
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 12:58 Friday 25th November, 2005
|
|
|
|
|
Hi Dave
Thanks Again for ur Co operation, i tried ur code but it is not working for me it say that "Type UInteger not defined"
i imported the system.net package but it is not workin
it is showing UInt16,UInt32,UInt64 But i think we cant use them.
i think i m missing some thing can u help me again.
i m using VS.net 2003 Enterprize Architect
thanks once again.
abhinav
|
|
|
|
|
In your case, use UInt32. I used VS2005.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave sorry but it is still not working...
Dim Ip32 As UInt32 = CType(TargetIp.Address, UInt32)
rc = SendARP(Ip32, 0, MacBytes, Length)
it is not not converting the TargetIP.Address to UInt32 say that "Public Property address as long is absolute and is family dependent"
i tried a lot other type of conversions but not working.
also while calling sendARP the second parameter 0 is also not converting i tried UInt32.parse(0) then it is not showing any error but dont seems to be working..
please help me.
abhinav
|
|
|
|
|
Did you ever get this to work? I am looking for some code to get all the mac address from out network. I beleive this is the same thing your tring to do.
Thanks
|
|
|
|
|
Ya it is working fine with some modifications thanks to dave .
what i m doing is taking the IP address in a text box from the user than showing the MAC address in another textbox
do like this :
form level declaration:
<br />
imports system.net<br />
<br />
<DllImport("iphlpapi.dll")> _<br />
Private Shared Function SendARP(ByVal DestIP As UInteger, ByVal SrcIP As UInteger, <Out()> ByVal pMacAddr() As Byte, ByRef PhyAddrLen As Integer) As UInteger<br />
End Function
than in any button event use this:
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click<br />
<br />
Try<br />
Dim addr As IPAddress = IPAddress.Parse(TextBox5.Text)<br />
Dim mac(6) As Byte<br />
Dim len As Integer = mac.Length<br />
SendARP(CType(addr.Address, UInteger), 0, mac, len)<br />
<br />
Dim macAddress As String = BitConverter.ToString(mac, 0, len)<br />
If macAddress = "" Then<br />
MsgBox("Cannot Resolve MAC from The Given IP Address")<br />
Return<br />
End If<br />
TextBox6.Text = macAddress<br />
<br />
Catch ex As System.FormatException<br />
MsgBox("Enter an Valid IP Address..." + ex, MsgBoxStyle.Critical)<br />
Catch ex As System.ArithmeticException<br />
MsgBox("Cannot extract MAC address " + ex, MsgBoxStyle.Critical)<br />
<br />
End Try<br />
<br />
End Sub
try it and tell me if u have any problem
abhinav
|
|
|
|
|
I have been searching all over the net for an answer to this and haven't been able to find anything. I know that this probably sounds petty but...
Has anyone else noticed that when you change the cursor in a .NET app to the "hand", that it doesn't have the shadow under it? Does anyone know a different way of displaying the hand cursor so that it looks like the "normal" link cursor in windows.
It just doesn't look right to me when I use that cursor. I mean, people that are used to using XP expect that when they hover over something that the cursor changes to the hand with the nice shadow under it. But when I use it, it just looks... Cheap, I guess is the right word.
|
|
|
|
|
If it's in XP, perhaps it's styled ? You can change the cursor to anything you like, but I don't know of any way to change the hand that is built in.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
I have one ISDN PCI card installed on w2k system for voice communication.
When ever there is a incoming call i should get an aural indication through a buzzer which is on board of ISDN card.
Now the problem is that while giving the device driver the supplier has not compiled the buzzer activating file and now i am not getting aural indication.
So we have thought that we will activate the buzzer by accessing the registers of the card for which the supplier has given the details.
The supplier has given that in the register AOE and ACFG1 of PSB21150 IPAC Ic if we put value 0x04 and 0xfb the buzzer will activate and 0xff the buzzer gets deactivated.The incoming call indication is coming as interrupt to my VB application program and during that time i should activate my buzzer.
So if any one knows about how to access the registers then please let me know.
vani
|
|
|
|
|
Hardware registers? Can't be done from VB. You need to write a Ring 0 .DLL, essentially a device driver, accesses that hardware for you and exports functions for your VB code to call. What's stopping you from doing this in VB is the HAL (Hardware Abstraction Layer) of any NT Kernel-based Windows OS - NT4, 2000, XP, 2003, Vista.
You can find an example of this technique here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey guys,
Is there anyway to make a panel scroll when AutoScroll is true? If so, how does one accomplish this? Thanks
Mike
Gaming at the GuildofBlades.com is the only way to really experiece the level 99 Soul-Sucking Sword!
|
|
|
|
|
hi all;
I need Tutorial or source code to open
web cam on vb.net form (application)
and capture picture form it and save
it ofcourse as bitmap image.
I searched and I didnt found any thing.
THANKS
AMR-CIS
|
|
|
|
|
Look in the windowsmedia sdk documentation, or even directx has some examples.
|
|
|
|
|
How can I enforce Referential Integrity between 2 or more of my DataTables in VB.NET.
Please help with some sample code and oblige.
R. A. Abbasi
|
|
|
|
|
This largely depends on your database schema but you would probably be better off doing this via database triggers and stored procedures rather than in a VB program.
...Steve
|
|
|
|
|
Thanks Steve for the idea. I will appreciate if you would elaborate more on it as I am not very well versed with databases.
Regards.
|
|
|
|
|
I presume this is for an assignment/project? Unfortunately I cannot give you a tutorial on r/i via what I'd consider the best way (i.e. triggers) as it would take too long and I honestly cannot afford to spend the time doing so. Your best bet therefore is to implement the r/i in discrete code in your program.
This definition explains it better than I can. I hope it helps http://databases.about.com/cs/administration/g/refintegrity.htm[^]:
Definition: Referential integrity is a database concept that ensures that relationships between tables remain consistent. When one table has a foreign key to another table, the concept of referential integrity states that you may not add a record to the table that contains the foreign key unless there is a corresponding record in the linked table. It also includes the techniques known as cascading update and cascading delete, which ensure that changes made to the linked table are reflected in the primary table.
Consider the situation where we have two tables: Employees and Managers. The Employees table has a foreign key attribute entitled ManagedBy which points to the record for that employee’s manager in the Managers table. Referential integrity enforces the following three rules:
1. We may not add a record to the Employees table unless the ManagedBy attribute poi
2. nts to a valid record in the Managers table. If the primary key for a record in the Managers table changes, all corresponding records in the Employees table must be modified using a cascading update.
3. If a record in the Managers table is deleted, all corresponding records in the Employees table must be deleted using a cascading delete.
...Steve
|
|
|
|
|
Thanks again Sterve for further help.
I just expect to have a sample Stored Procedure, which implements Referential Integrity. The rest, I may try to manage myself.
Sorry for asking for more of your valuable time.
Best regards.
|
|
|
|
|
No problem. I don't mean to sound too harsh it's just that to provide detailed instructions on this board does take some time to do properly and there are other resources (either on this board or other web sites) that do address your questions. It's just a matter of finding them. I'm very glad to help where I can.
If you have access to the MSDN documentation, it provides some great info on transact-SQL and stored procedures, triggers, referential integrity etc. - most may be available free on the web too. Try a Google search and I'm sure that there will be something in the first few results that may be of interest.
Take your time to learn about the subject properly. It is something that cannot be learnt in one night.
...Steve
|
|
|
|
|
Hello again,
I'm trying to have have a command button that will map drives in vb.net...I have some code that does it...but it uses a command shell to map the drive and if the drive is already in use it does not show an error messsage to say it is not connected...I would also like a message showing that it is connected...I'll show you my code hopefully someone can show me where I went wrong...thanks again guys!
Private Sub btnMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMap.Click
Dim ServerName As String
ServerName = txtIP.Text
Try
System.Diagnostics.Process.Start("net", "use h: \\" & ServerName & "\c$")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Andrew "Wondering where I went Wrong" Kong
|
|
|
|