|
Through utilities on your PC, you can use Task Manager or Process Viewer.
Through VB.Net, you can look at the My.Computer namespace.
Shreekar
|
|
|
|
|
hi,
i m using mysql & vb.net(winforms) in my application
will anyone help me in my Udate Query?
If conn.State = ConnectionState.Closed Then
Connect()
End If
Dim da As MySqlDataAdapter = New MySqlDataAdapter()
Dim cmd As MySqlCommand
Dim parm As MySqlParameter
' Create the SelectCommand.
cmd = New MySqlCommand("SELECT * FROM cust_mast WHERE CustName=?name", conn)
cmd.Parameters.Add("?name", MySqlDbType.VarChar, 45, txtCustName.Text)
da.SelectCommand = cmd
da.Fill(ds, "cust_mast")
If editFlag Then ''---------------Update Logic---------------
' Create the UpdateCommand.
cmd = New MySqlCommand("UPDATE cust_mast SET Address=?addr where custname=?
name;", conn)
cmd.Parameters.Add("?addr", MySqlDbType.VarChar, 200, txtAddr.Text)
parm = cmd.Parameters.Add("?custname", MySqlDbType.VarChar, 15, txtCustName.Text)
da.UpdateCommand = cmd
da.Update(ds, "cust_mast")
da.Fill(ds, "cust_mast")
Above code i wrote on my Update button,it is not giving any error but not affecting database.
Will u tell me how shuld i update my receords
priya
|
|
|
|
|
From my limited knowledge of parameterised SQL queries/statements,
priya_p233 wrote: WHERE CustName=?name", conn)
cmd.Parameters.Add("?name", MySqlDbType.VarChar, 45, txtCustName.Text)
this seems a bit wrong. It should read something like this:
WHERE CustName=?", conn)
and
cmd.Parameters.Add("name", MySqlDbType.VarChar, 45, txtCustName.Text)
Similarly for the update statements.
I may be wrong, so for better help, read up MSDN on parameterised SQL queries/statements.
Shreekar
|
|
|
|
|
You can use this sub
Public Sub ExceCommand(ByVal SqlCommand As String)
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
Dim Sqlcom As SqlCommand = New SqlCommand(SqlCommand)
Sqlcom.CommandType = CommandType.Text
Sqlcom.Connection = conn
Sqlcom.ExecuteNonQuery()
conn.Close()
End Sub
then you can call your sql statement as :
ExceCommand ("UPDATE cust_mast SET Address=..... where custname=.....")
-- modified at 0:28 Monday 22nd January, 2007
jooooo
|
|
|
|
|
hi,
Thnx for help. but if i m using above execute commant to update my table which contains many fields, it would be tedious to maintain txtbox & double cotes values...so i wrote tht code.
-thnx Regards Priya.
priya
|
|
|
|
|
Hi,
I want to show dynamically designed html page in the vb.net form using webbrowser control. I have the code like this,
Dim doc As mshtml.HTMLDocument
doc = AxWebBrowser1.Document()
But when I option strict on, it gives me error as
"Option Strict On disallows implicit conversions from 'System.Object' to 'mshtml.HTMLDocument'."
How do I resolve this any luck, If i switch off option strict then it works fine.
Regards,
Rams.
-- modified at 23:59 Sunday 21st January, 2007
Be simple and Be sample.
|
|
|
|
|
What do you mean by 'dynamically designed' - do you want to write a web designer ? You'll need to manipulate the HTML of the control for that.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
You can use the CType statement like below:
doc = ctype(AxWebBrowser1.Document(),mshtml.HTMLDocument)
However, you should be using the Web Browser Control that comes with .Net, not the COM one.
Hope this helps.
Shreekar
|
|
|
|
|
Thanks,
I had another problem, how do i set the left and top margin for the webbrowser control. Also, I need the focus to be always on last line.
Regards,
Rams.
Be simple and Be sample.
|
|
|
|
|
Do that in the HTML page.
Create an anchor tag and point the web URL to that anchor tag. like:
abc.html#tagname
Shreekar
|
|
|
|
|
Hi,
I set the left and top margins. Now i need how to auto scroll to last line of my browser control.
Regards
Rams.
Be simple and Be sample.
|
|
|
|
|
Hi,
I came to know the way to auto scroll to bottom, we need to write these following code in AxWebBrowser1 documentcomplete event as,
If e.pDisp Is AxWebBrowser1.Application Then
AxWebBrowser1.Document.parentWindow.scrollto(0, 99999999)
End If
I got problem if the option strict is on as "Option Strict On disallows late binding."
How to solve this error
Regards,
Rams.
Be simple and Be sample.
|
|
|
|
|
I'm using VB.Net and i can't retrieve my data from my database to my PDA.
Is it compulsary to put sqlserver ce provider?
I had try both of the below coding also can't retrieve.
1.) conn = New SqlCeConnection("Data Source = C:\teh\teh\MyDatabase.sdf")
2.) conn.ConnectionString = "Provider=.NET Framework Data Provider for SQL Server Mobile Edition; data source=C:\teh\teh\MyDatabase.sdf"
Can anyone correct my error or show a simple program?
Thanks.
|
|
|
|
|
HI everybody,
pls help me to find out this problem. I want to show time in the status bar. if i want to show CAPS LOCK, NUM LOCK, what steps i need to do.
sourish
|
|
|
|
|
Just add a StatusBar on your form (as you would a TextBox), add as many Panels you want in it. Then write any information you want in them.
The Quickest way to get info on small stuff like this is with your good friend "GOOGLE"
Try googling "vb.net Statusbar", "vb.net caps lock", "vb.net ....anything..."
|
|
|
|
|
Hello, i am trying to develop a derived tcplistener and a tcpclient. my derived tcpclient has a tcpclient and a string object as private fields. i would to be able to access the string field when my derived tcplistener object accepts a connection. How can i do that. please at the code below to see what i am trying to do.
Public Class MyTcpClient
Inherits TcpClient
Private _id As String
Private client As TcpClient
Public Sub New(ByVal myIpEndPoint As IPEndPoint)
MyBase.New(myIpEndPoint)
thisClient = New TcpClient
_id=nothing
End Sub
Public Property GetId() As String
Get
Return _id
End Get
Set(ByVal Value As String)
_id = Value
End Set
End Property
end class
Public Class MyTcpListener
Inherits TcpListener
Private myClient As MyTcpClient
Public Sub New(ByVal myIpEndPoint As IPEndPoint)
MyBase.New(myIpEndPoint)
myClient = New MyTcpClient
End Sub
public function MyAcceptTcpClient as MyTcpClient
'need help writing this part
end sub
end class
public class chat
public sub listen()
dim server as tcplistener
server = New MyTcpListener(thisIpEndPoint)
server.Start()
dim client as MyTcpClient
if server.pending then
client=? server.MyAcceptTcpClient
end if
end sub
end class
|
|
|
|
|
Sir/Madam,
Can I programically validate the email placed into the textbox.in vb.net(window application).
PLease help.
Thanks and regards
Pankaj
|
|
|
|
|
You can validate the format of the email address, but you can not validate that it is an existing address.
This is a regular expression pattern that I use sometimes to verify email addresses: "^[\w\-%~\.]+@[\w\-\.]+\.[\w]{2,4}$". It's based on the specification of how an email address may look, so it might be too strict as some email addresses does not follow the specification. You might want a more relaxed pattern like "^.+@.+\.\w{2,4}$".
---
Year happy = new Year(2007);
|
|
|
|
|
Sir/Madam,
I searched a email validation string
Function IsValidEmail(ByVal strIn As String) As Boolean
Return Regex.IsMatch(strIn, "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
End Function
Is this useful.
Thanks and Regards
Pankaj
|
|
|
|
|
Sir/madam,
Can i programically call the outlook to send the email in vb.net (Window Applications).
Thanks and Regards
|
|
|
|
|
Yes - google for MAPI.
It's much easier to just to take the mail server from outlook and pass it to .NET, thus fixing your code below.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Sir,
I meant , Is there any API that can help in calling the outlook for sending mail in the vb.net Window Appication.
Thanks and Regards
Pankaj
|
|
|
|
|
It's called MAPI. As I said. Google for MAPI, there's.NET wrappers for it. I use one in C#, it works great.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi, this is code from a VBA project so is not actually .NET but it should give you a good idea on how to go about this. Hope it helps!
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "COutlookMail"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'COutlookMail - Handles the sending of emails from Access using Outlook
'
'NOTE: Outlook must be available and running on the computer.
'
'==============================================
'This class uses structures to control the recipients and
'attachments. A more flexible and manageable model could be
'produced by the substitution of collection classes for these
'items, however this has the disadvantage that all the additional
'classes must also be present. The current model only requires
'a single class to be added to give mail functions.
'==============================================
Private oOutlookApp As Object
Private oMailItem As Object
'
'This class can be declared either with or without events
'If being used with events, the mail success flag event will
'be raised
Public Event MailSuccess(ByVal pState As Boolean)
'
Public Enum OFERecipientTypeConstants
rtcNormal = 1
rtcCarbonCopy = 2
rtcBlindCarbonCopy = 3
End Enum
'
Public Enum OFEAttachmentTypeConstants
atcSendAsFile = 1
atcSendAsLink = 2
End Enum
'
'-----------------------------------------------------------------------------------------------------------
Private mv_iAttachmentCount As Integer
Private mv_iRecipientCount As Integer
'-----------------------------------------------------------------------------------------------------------
Private mv_sLastErrorMessage As String
Private mv_lLastErrorNumber As Long
'
Private mv_bOutlookInitialseFailed As Boolean
'
Private strMail As OFEEmailDataStructure
'
'Attachments data structure
Private Type OFEAttachmentsDataStructure
FilePathAndName As String
DisplayName As String
AttachmentType As OFEAttachmentTypeConstants
End Type
'Recipients structure
Private Type OFEMailRecipientsStructure
RecipientName As String
RecipientType As OFERecipientTypeConstants
End Type
'Main mail structure
Private Type OFEEmailDataStructure
Attachments() As OFEAttachmentsDataStructure
Subject As String
Recipients() As OFEMailRecipientsStructure
MessageBody As String
MailSent As Boolean
SendErrors As Boolean
End Type
'
'Constants
Const mconstMAXRECIPIENTS As Integer = 10
Const mconstMAXATTACHMENTS As Integer = 10
'
Public Sub CreateNewMail(Optional ByVal SendCurrentMail As Boolean = False)
'Purpose: To initate a new email
'Inputs: Optional flag that sends any existing mail before initialising for a new one.
Dim bResult As Boolean
If SendCurrentMail = True Then
If strMail.MailSent = False Then
SendOutlookMail
End If
End If
ClearSTR
End Sub
Private Sub Class_Initialize()
'Creates the Outlook object
On Error Resume Next
Err.Clear
Set oOutlookApp = CreateObject("Outlook.Application")
If Err.Number <> 0 Then
'Events cannot be raised in the initialise event so a flag must be set
'for examination later
mv_lLastErrorNumber = Err.Number
mv_sLastErrorMessage = Err.Description
mv_bOutlookInitialseFailed = True
End If
ReDim strMail.Attachments(1 To mconstMAXATTACHMENTS) As OFEAttachmentsDataStructure
ReDim strMail.Recipients(1 To mconstMAXRECIPIENTS) As OFEMailRecipientsStructure
ClearSTR
On Error GoTo 0
End Sub
Private Sub Class_Terminate()
On Error Resume Next
Set oOutlookApp = Nothing
Set oMailItem = Nothing
On Error GoTo 0
End Sub
Public Sub SendOutlookMail(Optional ByVal RequireReadReceipt As Boolean = True, Optional ByVal RequireDeliveryReport As Boolean = False)
'Purpose: Sends the email and any attachments in the list
Dim iLoop As Integer
Dim oRecipient As Object
'Dim sWorkbook As String
Dim x As Variant
On Error GoTo ERROR_SOM
'Before Send call
'sWorkbook = ActiveWorkbook.Name
'
strMail.SendErrors = False
Set oMailItem = oOutlookApp.CreateItem(0)
With oMailItem
.Subject = strMail.Subject
If mv_iRecipientCount > 1 Then
For iLoop = 1 To mv_iRecipientCount
Set oRecipient = .Recipients.Add(strMail.Recipients(iLoop).RecipientName)
Select Case strMail.Recipients(iLoop).RecipientType
Case OFERecipientTypeConstants.rtcCarbonCopy
oRecipient.Type = 2
Case OFERecipientTypeConstants.rtcBlindCarbonCopy
oRecipient.Type = 3
End Select
Next
Else
.To = strMail.Recipients(1).RecipientName
End If
.Body = strMail.MessageBody
If mv_iAttachmentCount > 0 Then
For iLoop = 1 To mv_iAttachmentCount
If Trim(strMail.Attachments(iLoop).FilePathAndName) > "" Then
If strMail.Attachments(iLoop).AttachmentType = atcSendAsFile Then
.Attachments.Add strMail.Attachments(iLoop).FilePathAndName, 1, iLoop, strMail.Attachments(iLoop).DisplayName
Else
.Attachments.Add strMail.Attachments(iLoop).FilePathAndName, 4, iLoop, strMail.Attachments(iLoop).DisplayName
End If
End If
Next
End If
.ReadReceiptRequested = RequireReadReceipt
.OriginatorDeliveryReportRequested = RequireDeliveryReport
.Send
End With
strMail.MailSent = True
RaiseEvent MailSuccess(True)
'
Set oMailItem = Nothing
'
EXIT_SOM:
Exit Sub
ERROR_SOM:
strMail.SendErrors = False
mv_lLastErrorNumber = Err.Number
mv_sLastErrorMessage = Err.Description
RaiseEvent MailSuccess(False)
Resume EXIT_SOM
End Sub
Public Property Get InitialiseFailed() As Boolean
InitialiseFailed = mv_bOutlookInitialseFailed
End Property
Public Property Get LastErrorNumber() As Long
LastErrorNumber = mv_lLastErrorNumber
End Property
Public Property Get LastErrorMessage() As String
LastErrorMessage = mv_sLastErrorMessage
End Property
Private Sub ClearSTR()
Dim iLoop As Integer
'The mail sent flag is set to true so that an initialised empty mail does
'not get sent. Passing information to the properties will set the mail sent
'flag to False
strMail.MailSent = True
strMail.MessageBody = ""
strMail.Subject = ""
For iLoop = 1 To mconstMAXATTACHMENTS
strMail.Attachments(iLoop).DisplayName = ""
strMail.Attachments(iLoop).FilePathAndName = ""
Next
For iLoop = 1 To mconstMAXRECIPIENTS
strMail.Recipients(iLoop).RecipientName = ""
strMail.Recipients(iLoop).RecipientType = rtcNormal
Next
mv_iRecipientCount = 0
mv_iAttachmentCount = 0
End Sub
Public Function AddRecipient(ByVal NewRecipentName As String, ByVal NewRecipientType As OFERecipientTypeConstants) As Boolean
If mv_iRecipientCount < mconstMAXRECIPIENTS Then
mv_iRecipientCount = mv_iRecipientCount + 1
strMail.Recipients(mv_iRecipientCount).RecipientName = NewRecipentName
strMail.Recipients(mv_iRecipientCount).RecipientType = NewRecipientType
strMail.MailSent = False
AddRecipient = True
Else
mv_lLastErrorNumber = -1
mv_sLastErrorMessage = "The maximum number of recipients has been reached"
AddRecipient = False
End If
End Function
Public Function AddAttachment(ByVal NewFilePathAndName As String, ByVal NewAttachmentType As OFEAttachmentTypeConstants, Optional ByVal NewDisplayName As String = "") As Boolean
If mv_iAttachmentCount < mconstMAXATTACHMENTS Then
mv_iAttachmentCount = mv_iAttachmentCount + 1
strMail.Attachments(mv_iAttachmentCount).DisplayName = NewDisplayName
strMail.Attachments(mv_iAttachmentCount).FilePathAndName = NewFilePathAndName
strMail.Attachments(mv_iAttachmentCount).AttachmentType = NewAttachmentType
strMail.MailSent = False
AddAttachment = True
Else
mv_lLastErrorNumber = -2
mv_sLastErrorMessage = "The maximum number of attachments has been reached"
AddAttachment = False
End If
End Function
Public Property Get AttachmentCount() As Integer
AttachmentCount = mv_iAttachmentCount
End Property
Public Property Get RecipientCount() As Integer
RecipientCount = mv_iRecipientCount
End Property
Public Property Get AttachmentFile(ByVal Index As Integer) As String
If (Index < 1) Or (Index > mconstMAXATTACHMENTS) Then
AttachmentFile = ""
Else
AttachmentFile = strMail.Attachments(Index).FilePathAndName
End If
End Property
Public Property Get AttachmentDisplayName(ByVal Index As Integer) As String
If (Index < 1) Or (Index > mconstMAXATTACHMENTS) Then
AttachmentDisplayName = ""
Else
AttachmentDisplayName = strMail.Attachments(Index).DisplayName
End If
End Property
Public Property Get AttachmentType(ByVal Index As Integer) As Long
If (Index < 1) Or (Index > mconstMAXATTACHMENTS) Then
AttachmentType = 0
Else
AttachmentType = strMail.Attachments(Index).AttachmentType
End If
End Property
Public Property Get RecipientNameOrList(ByVal Index As Integer) As String
If (Index < 1) Or (Index > mconstMAXRECIPIENTS) Then
RecipientNameOrList = ""
Else
RecipientNameOrList = strMail.Recipients(Index).RecipientName
End If
End Property
Public Property Get RecipientType(ByVal Index As Integer) As Long
If (Index < 1) Or (Index > mconstMAXRECIPIENTS) Then
RecipientType = ""
Else
RecipientType = strMail.Recipients(Index).RecipientType
End If
End Property
Public Property Get SendErrors() As Boolean
SendErrors = strMail.SendErrors
End Property
Public Property Get MessageBody() As String
MessageBody = strMail.MessageBody
End Property
Public Property Let MessageBody(ByVal NewMessage As String)
strMail.MessageBody = NewMessage
strMail.MailSent = False
End Property
Public Property Get Subject() As String
Subject = strMail.Subject
End Property
Public Property Let Subject(ByVal NewSubject As String)
strMail.Subject = NewSubject
strMail.MailSent = False
End Property
David Loring
!! Keep Music Live !!
|
|
|
|
|
Sir/madam,
I am using the following code to send the mail using vb.net (Window Appications)
It is generating the following error.
Failure sending mail.
Try
Dim oMessage As MailMessage = New MailMessage
oMessage.Body = "MESSAGE COMES HERE"
oMessage.To.Add(TO_User_Email)
Dim oFrom As MailAddress = New MailAddress(FROM_User_Email)
oMessage.From = oFrom
oMessage.Subject = "SUBJECT COMES HERE"
'oMessage.IsBodyHtml = True
'oMessage.Priority = MailPriority.Normal
Dim oSMTP As SmtpClient = New SmtpClient("Localhost")
oSMTP.Send(oMessage)
Catch ex As Exception
End Try
Please help.
Thanks and regards
Pankaj
|
|
|
|