|
|
i need to bind a datagrid to a data reader,
i also want to be able to make use of the datagrids
data editing abilities, is it posible to take changes made to the data grid
and use the datareader to update the database table and or relevant fields??
plz help
thanx
Afzal Hassen
|
|
|
|
|
The DataReader classes are forward-only readers. They really can't make updates to your database. If you want edit capabilities in your datagrid, you'll have to use a DataAdapter instead. SqlDataAdpeter class docs[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi there -
i defined the following, serializable class. main focus lies on the attribut img, which is an byte array.
Imports System.Drawing
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters
<serializable()> Public Class ScreenShot
Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As String) As Integer
Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Integer) As Integer
Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer
Private Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer
Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As Integer, ByVal op As Integer) As Integer
Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As Integer
Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As Integer
Const SRCCOPY As Integer = &HCC0020
Private FW, FH As Integer
Public Shared img As Byte()
Public Sub CaptureScreen()
Dim info As SerializationInfo
Dim hSDC, hMDC As Integer
Dim hBMP, hBMPOld As Integer
Dim r As Integer
hSDC = CreateDC("DISPLAY", "", "", "")
hMDC = CreateCompatibleDC(hSDC)
FW = GetDeviceCaps(hSDC, 8)
FH = GetDeviceCaps(hSDC, 10)
hBMP = CreateCompatibleBitmap(hSDC, FW, FH)
hBMPOld = SelectObject(hMDC, hBMP)
r = BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, 13369376)
hBMP = SelectObject(hMDC, hBMPOld)
r = DeleteDC(hSDC)
r = DeleteDC(hMDC)
Dim oBackground As Bitmap
oBackground = Image.FromHbitmap(New IntPtr(hBMP))
Dim formatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
Dim ms As New System.IO.MemoryStream()
formatter.Serialize(ms, oBackground)
img = ms.GetBuffer()
ms.Flush()
End Sub
Public ReadOnly Property _getImage() As Byte()
Get
Return img
End Get
End Property
End Class
now i want to transfer an object of this class by remoting, doing the following:
Dim getScreenShot As New Interfaces.ScreenShot()
Try
getScreenShot.CaptureScreen()
remServer._giveScreenShot(getScreenShot)
Catch e As Exception
MessageBox.Show(e.ToString)
End Try
This calls a function on the server, that looks like this:
Public Sub _giveScreenShot(ByVal screenShot As Interfaces.ScreenShot) Implements IServer._giveScreenShot
Dim _ms As New System.IO.MemoryStream()
_ms.Write(screenShot._getImage, 0, screenShot._getImage.Length)
Dim _bmp As New Bitmap(_ms)
_ms.Close()
Me._schoolMain.Screenshot.Image = CType(_bmp, Image)
End Sub
the problem i have: the _getImage Method of my screenShot-Object returns "Nothing"... so the byte-array seems to get lost while remoting.
but i don't know why - it is serialized ... what did i wrong???
thanks for help.
|
|
|
|
|
I know that controls for WinForm and WebForm
are come from different classes even they shares
similar name such as ListBox.
BTW, anyone can guide me that does it possible to
convert existing WinForm to WebForm application?
Any tools or techniques are welcome.
Thanks in advance.
|
|
|
|
|
Because the way a Web application works is very different from a Windows Form, your best bet is to rewirte your app form scratch. If it was written properly in Windows Forms, you should only have to rewrite the user interface. Any database code should be in seperate classes, that way they can be shared between the two, usually without any modification.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
hi i am a newcomer in vb.net i have installed visual studio dot net on my pc .My applications work on my pc but does not work on any other pc on which Dot net frame work in not installed . Is there any way to run my application on the pc on which Visual Studio is not installed
faheem
|
|
|
|
|
As long as the other computers simply have the .NET Framework installed, your programs should work fine.
Happy Programming and may God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
N-Tech Productions
http://www.n-tp.com/
|
|
|
|
|
Faheem Ahmad wrote:
My applications work on my pc but does not work on any other pc on which Dot net frame work in not installed
You must install the .NET Framework on each PC that your .NET application is to run on.
Faheem Ahmad wrote:
Is there any way to run my application on the pc on which Visual Studio is not installed
Yes. Install the .NET Framework on each PC that your application is to run on.
Remember. Visual Studio IS NOT the same as the .NET Framework.
"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!
|
|
|
|
|
Please anybody who know and tell me the simple program for insert, edit, cancel and delete using ADO in VB6, I have to learn it from the first, but currently I use the Data Control for insert, edit,cancel and delete. The provider = microsoft.jet.oledb.4.0.
;);P
Best Regards,
Ahmad Rifai Yusuf
|
|
|
|
|
Simple? Anything but... Articles and samples concerning VB6 and ADO are becomming increasingly difficult to find over the last three years. They've been pretty much replaced by VB.NET and ADO.NET. Your best bet is to pick up a book on it. Believe it or not, "Visual Basic 6 Database Programming for Dummies" has turned out to be pretty good on the subject.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I read on www.visualbasic.net[^] that I could send mail messages by using the objects available in System.Web.Mail, so I tried including the line Imports System.Web.Mail at the top of my code, but there was no System.Web.Mail! So is there any way to send e-mails using a different method in VB .NET?
O_o
|
|
|
|
|
In order to use the System.Web.Mail namespace, you have to add to your project, a reference to the System.Web.dll assembly. Go to your References folder in the Solution Explorer, right-click the References folder, then click Add Reference . On the .NET tab, scroll down the list until you find System.Web.dll and double-click it. The reference should appear in the bottom window of the dialog, then click OK. Now you can add the Imports System.Web.Mail at the top of your code.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Wow! Thanks, that really helped. Now I know how to add a reference too
y helothar noob
|
|
|
|
|
When I shift to a tab page and turn to the previous again, selectedIndex changed event is triggered for comboboxes on newly focused tab. When I shift to another program and come back to program form key up events are fired! To prevent this I used boolean flags but isn't this behaviour stupid? There must be a more elegant solution.
Thanks a lot.
|
|
|
|
|
Microsoft Knowledge Base Article - 820633
PRB: Unexpected Events Are Raised When You Switch Between Tab Pages with a ComboBox or a ListBox Control
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B820633
|
|
|
|
|
Clickety[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks. It seems that our boolean flags will stay in the code.
|
|
|
|
|
Hello all,
I'm trying to change the color of the text of a DateTimePicker, just the text that appear in the control after we clicked in a date on the calendar.
I've already used the ForeColor and it didn't work and I tryed the CalendarForeColor and they changed the color of the calendar, not the text that I'd like to.
What should I do.
Thanks.
--------------------------------
Clayton Valdo
--
Clayton
|
|
|
|
|
Can somebody tell me how to make a tree view in vb 6, i need it froom beginning. I am trying to build a maintenance program.
|
|
|
|
|
hello there -
i have two applications. the first one save a bitmapfile to a certain directory.
the second one just reads this bitmapfile into a picturebox.
the first time everything works fine.
but as soon as the first application wants to write again the file to the same path and filename, an exception is thrown. i know why, because application two seems to have the bitmapfile protected from overwriting, because it uses it in the picture box.
but i want to have the actual bitmap in the picturebox. any idea how i can solve my problem?
Save-Function of Application 1:
picPath = "\\Matrix\Kunden\server.bmp"
getScreenShot._getImage.Save(picPath)
Read-Function of Application 2:
path = "\\Matrix\Kunden\server.bmp"
Me._schoolMain.Screenshot.Image = screenShot.FromFile(path)
thx for any help.
tom
|
|
|
|
|
Your having this problem, not because the image is shown in a PictureBox, but because the Bitmap object in your 2nd application is keeping an open file handle to the image file that your loading.
The workaround can be found here[^] on MSDN.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
well, thank you for the link. i tried it this way but something i seem to do wrong ...
here the code:
Public Sub _getClientScreenShot() Implements IServer._getClientScreenShot
Dim user As IClient
Dim path As String
Dim screenShot, screenShotTemp As Bitmap
Dim screenGraphics As Graphics
For Each user In _clients.Values
Try
user._captureScreen()
path = "\\Matrix\Kunden\" + user._computerName.ToString + ".bmp"
screenShotTemp = Image.FromFile(path)
screenGraphics.FromImage(screenShotTemp)
screenGraphics.DrawImage(screenShot, 0, 0)
screenShotTemp.Dispose()
screenGraphics.Dispose()
Me._schoolMain.Screenshot.Image = screenShot
Catch e As Exception
Me._schoolMain.Info.Text = "Exception in Screenshot: " & e.ToString
End Try
Next
End Sub
unfortunately, the failure got worse. the application that calls this function hangs up...
what did i wrong?
|
|
|
|
|
tommy_tanaka wrote:
path = "\\Matrix\Kunden\" + user._computerName.ToString + ".bmp"
First, you don't need to call .ToString here. _computerName is already a String and doesn't need to be converted to one.
tommy_tanaka wrote:
Dim screenShot, screenShotTemp As Bitmap
Dim screenGraphics As Graphics
For Each user In _clients.Values
Try
user._captureScreen()
path = "\\Matrix\Kunden\" + user._computerName.ToString + ".bmp"
screenShotTemp = Image.FromFile(path)
screenGraphics.FromImage(screenShotTemp)
screenGraphics.DrawImage(screenShot, 0, 0)
screenShotTemp.Dispose()
screenGraphics.Dispose()
Me._schoolMain.Screenshot.Image = screenShot
Second, you're doing alot of unecessary work and this is where your hanging up. All you need to do is load the picture into your screenShotTemp and make a copy of it using a new Bitmap object. Then use the copy as your PictureBox source image and release the original image in your temp variable.
Dim screenShotTemp As Bitmap
Dim path As String
.
.
.
path = "\\Matrix\Kunden\" + user._computerName + ".bmp"
screenShotTemp = Image.FromFile(path)
Dim screenShot As New Bitmap(screenShotTemp)
PictureBox1.Image = screenShot
screenShotTemp.Dispose()
The Bitmap class has about a dozen different constructors. Read up on them here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|