|
I have just read out the article
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q302896
Which is using to add a button on the command bar to Outlook.
I have try to run the provide code,
The button is added.
But I don't know how to remove(delete) this Add-in completely, not just hide it.
Thank you!!
|
|
|
|
|
I am new to VB.NET. I really try a few ways but seems like this is not run. I'm migrating a VB Engine to VB.NET. The following are the code I need to change to VB.NET. Really wish someone can give me a help here. Thank you all so much~!
Private Sub Spam_Now()
Dim conStr1 As String
Dim con1 As ADODB.Connection
Dim rs1, rs2, rs3 As ADODB.Recordset
Dim sql1, sql2, sql3 As String
conStr1 = "provider=SQLOLEDB;data source=" & DellServerIP _
& ";database=pre_sms;uid=sa;pwd=" & DellServerPass
Set con1 = New ADODB.Connection
con1.Open conStr1
Set rs1 = New ADODB.Recordset
Set rs1.ActiveConnection = con1
Set rs2 = New ADODB.Recordset
Set rs2.ActiveConnection = con1
sql1 = "SELECT TOP 20 * FROM TT_Member WHERE Reminder = '0' AND Status = '1'"
rs1.Open (sql1)
If rs1.EOF And rs1.BOF Then
Label1.Caption = "Finished - " & Now
Else
Do Until rs1.EOF
Label1.Caption = "Spamming - " & Now
OriginatingAddress = rs1.Fields("Mobile_No").Value
If Mid(OriginatingAddress, 1, 3) = "601" Then
Telco = 2
ElseIf Mid(OriginatingAddress, 1, 3) = "019" Then
Telco = 9
End If
Reminder_Msg = "Free Msg.Subscription Reminder.Fee:Auto renewal datedate, unless cancelled. To cancel, send STOP TT to 32132."
MT_Msg = Reminder_Msg
MT_Msg = Replace(MT_Msg, "datedate", Renewal_Date3)
Call Sent_MT
Call Close_Record
rs1.MoveNext
Loop
End If
End Sub
|
|
|
|
|
It's not complete solution. But you can change as you like.
It use SQL Server database.
Private Sub Spam_Now()
Dim conStr1 As String
Dim con1 As SqlClient.SqlConnection 'ADODB.Connection
Dim cmd As SqlClient.SqlCommand
Dim rd1, rd2, rd3 As SqlClient.SqlDataReader 'ADODB.Recordset
Dim sql1, sql2, sql3 As String
Dim strUserName As String = "sa" 'set your user name
Dim strPwd As String = "sa" 'set your password
Dim strDatabase As String = "pubs" 'set your database name
Try
conStr1 = "packet size=4096;user id=" & strUserName & ";password=" & strPwd & ";data source=TEST-PC;persist security info=False;initial catalog=" + strDatabase
'conStr1 = "provider=SQLOLEDB;data source=" & DellServerIP _
'& ";database=pre_sms;uid=sa;pwd=" & DellServerPass
con1 = New SqlClient.SqlConnection(conStr1) 'ADODB.Connection
cmd = New SqlClient.SqlCommand(Nothing, con1)
If con1.State = ConnectionState.Closed Then con1.Open()
'rs1 = New ADODB.Recordset
'rs1.ActiveConnection = con1
'rs2 = New ADODB.Recordset
'rs2.ActiveConnection = con1
sql1 = "SELECT TOP 20 * FROM TT_Member WHERE Reminder = '0' AND Status = '1'"
cmd.CommandText = sql1
rd1 = cmd.ExecuteReader()
If rd1.HasRows Then
While rd1.Read
' rd1("ColName")
'
End While
End If
'**********************************************
If Not rd1.IsClosed Then rd1.Close()
Catch ex As Exception
'Error handling code here
Finally
If con1.State = ConnectionState.Open Then con1.Close()
con1.Dispose()
cmd.Dispose()
End Try
'If rs1.EOF And rs1.BOF Then
' Label1.Caption = "Finished - " & Now
'Else
' Do Until rs1.EOF
' Label1.Caption = "Spamming - " & Now
' OriginatingAddress = rs1.Fields("Mobile_No").Value
' If Mid(OriginatingAddress, 1, 3) = "601" Then
' Telco = 2
' ElseIf Mid(OriginatingAddress, 1, 3) = "019" Then
' Telco = 9
' End If
' Reminder_Msg = "Free Msg.Subscription Reminder.Fee:Auto renewal datedate, unless cancelled. To cancel, send STOP TT to 32132."
' MT_Msg = Reminder_Msg
' MT_Msg = Replace(MT_Msg, "datedate", Renewal_Date3)
' Call Sent_MT()
' Call Close_Record()
' rs1.MoveNext()
' Loop
'End If
End Sub
!alien!
|
|
|
|
|
Hello,can you give me a more detail solution? I'm really new to this VB.NET. How should I change,It still doesn't really works for me here. Can you please help me more?
Thank you so much~!
|
|
|
|
|
I removed some unused code, and converted it. It's pretty close to your original code and quite straightforward, so you should be able to follow it.
Private Sub Spam_Now()
Dim conStr1 As String
Dim con1 As SqlConnection
Dim reader As IDataReader
Dim sql1 As String
Dim command As SQlCommand
conStr1 = "provider=SQLOLEDB;data source=" & DellServerIP _
& ";database=pre_sms;uid=sa;pwd=" & DellServerPass
con1 = New SqlConnection(conStr1)
sql1 = "SELECT TOP 20 Mobile_No FROM TT_Member WHERE Reminder = '0' AND Status = '1'"
command = New SqlCommand(sql1, con1)
reader = command.ExecuteReader()
If not reader.Read() Then
Label1.Caption = "Finished - " & Now
Else
Do
Label1.Caption = "Spamming - " & Now
OriginatingAddress = reader.GetString("Mobile_No")
If OriginatingAddress.Substring(0, 3) = "601" Then
Telco = 2
ElseIf OriginatingAddress.Substring(0, 3) = "019" Then
Telco = 9
End If
Reminder_Msg = "Free Msg.Subscription Reminder.Fee:Auto renewal datedate, unless cancelled. To cancel, send STOP TT to 32132."
MT_Msg = Reminder_Msg
MT_Msg = Replace(MT_Msg, "datedate", Renewal_Date3)
Call Sent_MT()
Call Close_Record()
Loop Until not reader.Read()
End If
End Sub
One difference between a Recordset and a DataReader that can be good to know, is that you use the Read() method to both advance the row pointer and check for more rows, just like you use MoveNext() and EOF with a recordset. Also you have to call Read() before you can read any data from the DataReader, it doesn't automatically read the first record as a Recordset does.
---
b { font-weight: normal; }
|
|
|
|
|
Hello Mr. Guffa,Ur solution is really a new thing for me. But I found that was not working properly for me when I test it. The following lines is not running during I execute it. But it doesn't promp me any error in my Visual Studio 2003. This is the line that it doesn't run as expected:
OriginatingAddress = reader.GetString("Mobile_No")
I put a messagebox to check the value inside Originating Address,but it show nothing inside. Do you have any idea with this? My database for this is fill will a number.
Hope to get some solution from you all here.
Thanks~!
|
|
|
|
|
I have an access db table with a column of type ole object. When I right click in the column a context menu displays that allows me to add an image.
Once the image is added the column displays 'bitmap image'. If I add an image via ado.net the column displays 'long binary format'.
How can I convert these existing 'bitmap image' items to 'long binary format'? The bitmap ones are causing problems with object and control references. For example I can declere a bitmap object and load from a stream as it throws an exception.
Thanks
Glenn
|
|
|
|
|
|
Let me rephrase my question.
I'm using vb.net. I'm doing the following and this exeption was thrown. ex.message = invalid parameter used.
The msaccess db table column is set to type ole object. Try this, go to the db table and right click on the column and click inser object and insert a bmp. The column value will now display bitmap image. Try your code against that and you'll experience the problem. Why?
Dim cmd As OleDbCommand = New OleDbCommand(sql, cnn)
cnn.Open()
Dim b() As Byte
b = cmd.ExecuteScalar()
cnn.Close()
If (b.Length > 0) Then
Dim stream As New MemoryStream(b, True)
stream.Write(b, 0, b.Length)
'Display image
Dim PictureBox1 As New System.Windows.Forms.PictureBox
'exception is thrown at this statement
PictureBox1.Image = New Bitmap(stream)
'ex.message = invalid parameter used.
stream.Close()
End If
'conn.Close()
Why?
Thanks,
Glenn
|
|
|
|
|
The links Roath gave you have nothing to do with converting an OLEObject bitmap image to a usable Bitmap in VB.NET.
I think you're looking for something more like this:
Imports System.Io
.
.
.
Dim ms As New MemoryStream
Dim oleData() As Byte = dataRow.Item("ColumnName")
ms.Write(oleData, 78, oleData.Length - 78)
Dim bm As New Bitmap(ms)
PictureBox1.Image = bm
You got the right idea, just the wrong offset when you wrote your image data to the MemoryStream.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You hit the nail right on the head. The offset was all I needed. I searched high and low for this info and could not find anything. How did you know this? Alow is their any way to test if the column value is a ole data bitmap or an image in long binary format. I may incounter both types when running the conversion.
Thanks
Glenn Romaniuk
.net virtuoso
|
|
|
|
|
I've seen the code before, but I can't remember where. I thought the offset was kind of odd myself.
As for determining which type the data is, you might want to take a look at the first bytes of each type to find a pattern between the two. I think the OLE objects will have a consistent header, while the pictures might have a different header.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: The links Roath gave you have nothing to do with converting an OLEObject bitmap image to a usable Bitmap in VB.NET.
My name is Kanel, don't call me Roath. Roath is my family name.
|
|
|
|
|
Well as the title indicates I have a search that populates a datagrid with results. I am wondering if i click the first cell in the datagrid if I can then copy that informaton into another form. Since there can be duplicate people by last name, I need to be sure that the correct one is A clicked then the form is populated withthe users information. Is this possible with datagrids in VB6. i have seen tons of references to asp.net but notta with VB6
After playing a bit
<br />
Private Sub DataGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<br />
MsgBox "clicked"<br />
End Sub<br />
works when a record is clicked So the next step would be to copy the data or at least 1 field say a unique ID i could i guess perform another search and populate the form with that search. But would rather copy the data from the datagrid
-- modified at 17:15 Tuesday 7th February, 2006
|
|
|
|
|
Well this doesn't quite work
<br />
With Form1<br />
For I = 1 To DataGrid1.Col + 1<br />
FrmSearch.DataGrid1.Col = I<br />
Form1.Text1(I).Text = FrmSearch.DataGrid1.Text<br />
Next I<br />
End With<br />
Load Form1<br />
Form1.Visible = True
Any ideas?
This results in 1 field from the datagrid placed into 1 textbox on the other form
-- modified at 17:57 Tuesday 7th February, 2006
|
|
|
|
|
Well I have revamped my process
here is the steps involved
1.search for a customer by last name Done
2.click Search Done
3. see results in datagrid Done
4. select customerID cell which could be in any row
for the correct customer with mouse click Not Done
> Capture mouse click?
> Capture cell value ?
5. return the clicked cell's value to a textbox. Not Done
|
|
|
|
|
During looping throug the directories the program tries to access the system directory
"C:\System Volume Information". The access is denied by the system and I receive an error message.
See subject.
So far I know there are two pssibilities
1. To avoid the error with ATTRIBUTE
2. To catch the error with TRY.
If I use ATTRIBUTE I don't know how the code looks and where I have to implemente it.
If I use TRY the program does not continue the loop.
Mein Code :
Private Function FindFiles(ByRef FoundFiles As ArrayList, ByVal dirname As String, ByVal filespec As String, ByVal recurseDirs As Boolean) As ArrayList
Dim strFilter As String = filespec
Dim m_arExt() As String = strFilter.Split(";")
Dim dic As New IO.DirectoryInfo(dirname)
For Each Filter As String In m_arExt
For Each fname As String In System.IO.Directory.GetFiles(dirname, Filter)
FoundFiles.Add(fname)
Next fname
' recurse on subdirectory if so requested
If recurseDirs Then
For Each dname As String In System.IO.Directory.GetDirectories(dirname)
FindFiles(FoundFiles, dname, filespec, recurseDirs)
Next dname
End If
Next Filter
Return FoundFiles
End Function
Can anybody assist me to sove the problem ?
Best regards Theo
|
|
|
|
|
Avoid exception handling in the normal flow of the code. Creating exception objects is rather costly.
Look at the attributes. Here is the documentation of the codes:
MSDN: FileAttributes Enumeration[^]
---
b { font-weight: normal; }
|
|
|
|
|
The articlke about ATTRIBUTE I found already. My problem is, I cant find a solution with this description. (Newbie).
Theo
|
|
|
|
|
You should have security permission to process a task on the directory which is protected by the OS. Therefore, define System.Security.IPermission() in the imports section and then create fileiopermission for the specific files under the specific directory.
|
|
|
|
|
Thank very much you for your answer.
I did was you suggest.
Imports System.Security
and, to get full access
Dim f As New Permissions.FileIOPermission(Permissions.PermissionState.None)
f.AllLocalFiles = Permissions.FileIOPermissionAccess.AllAccess
The result : I still got an error.
But I dont want to access the system directories. My favorite solution would be to avoid the error by using the ATTRIBUTE Class. But I dont now how to use. Do you have an idea ?
Best regards Theo
|
|
|
|
|
Hi!
You are able to reach to attributes of the files or even for directories. Here is an example. You have used an array what keeps all the files names. Therefore you can call their attributes.
File.SetAttributes(FileName, FileAttributes.ReadOnly)
|
|
|
|
|
Hi Journey,
The error comes up in this line of my code :
For Each fname As String In System.IO.Directory.GetFiles(dirname, Filter)
How can I interate your line
File.SetAttributes(FileName, FileAttributes.ReadOnly)
into my code ?
Regards Theo
|
|
|
|
|
You shouldn't get any error messages because of trying to reach the system directory. I did a few samples and those worked out in my puter. Here is a good sample how to recurse the directories. Check this out!
' For Directory.GetFiles and Directory.GetDirectories
' For File.Exists, Directory.Exists
Imports System
Imports System.IO
Imports System.Collections
Public Class RecursiveFileProcessor
Public Overloads Shared Sub Main(ByVal args() As String)
Dim path As String
For Each path In args
If File.Exists(path) Then
' This path is a file.
ProcessFile(path)
Else
If Directory.Exists(path) Then
' This path is a directory.
ProcessDirectory(path)
Else
Console.WriteLine("{0} is not a valid file or directory.", path)
End If
End If
Next path
End Sub 'Main
' Process all files in the directory passed in, recurse on any directories
' that are found, and process the files they contain.
Public Shared Sub ProcessDirectory(ByVal targetDirectory As String)
Dim fileEntries As String() = Directory.GetFiles(targetDirectory)
' Process the list of files found in the directory.
Dim fileName As String
For Each fileName In fileEntries
ProcessFile(fileName)
Next fileName
Dim subdirectoryEntries As String() = Directory.GetDirectories(targetDirectory)
' Recurse into subdirectories of this directory.
Dim subdirectory As String
For Each subdirectory In subdirectoryEntries
ProcessDirectory(subdirectory)
Next subdirectory
End Sub 'ProcessDirectory
' Insert logic for processing found files here.
Public Shared Sub ProcessFile(ByVal path As String)
Console.WriteLine("Processed file '{0}'.", path)
End Sub 'ProcessFile
End Class 'RecursiveFileProcessor
|
|
|
|
|
Good morning Journey,
Thanks for taking care of my problem. I havn't check your code yet because I'm a little bit tired for spending my nights in front of the computer. I find another solution with the ATTRIBUTE Class. It's works too. I will check your code next week because my leave starts.
If you can find a hidden problem in my code please tell.
Public Function BrowseForMediaFiles(ByRef AL_MediaFileAndPath As ArrayList, ByVal selectedPath As String, ByVal exTensions() As String) As ArrayList
Dim dic As New IO.DirectoryInfo(selectedPath)
Dim AtrrDir As Object
For Each Filter As String In exTensions
For Each fname As String In System.IO.Directory.GetFiles(selectedPath, "*." + Filter, IO.SearchOption.TopDirectoryOnly)
AL_MediaFileAndPath.Add(fname)
Next fname
Next Filter
For Each dirc As IO.DirectoryInfo In dic.GetDirectories()
AtrrDir = dirc.Attributes 'Determine directory attribut.
Select Case AtrrDir
Case 22, 8214
'AtrrDir=22 The directory is a system directory. The directory is part
'of the operating system or used exclusively by the operating system
Case Else
For Each Filter As String In exTensions
For Each fname As String In System.IO.Directory.GetFiles(dirc.FullName, "*." + Filter, IO.SearchOption.AllDirectories)
AL_MediaFileAndPath.Add(fname)
Next fname
Next Filter
End Select
Next dirc
Return AL_MediaFileAndPath
End Function 'BrowseForMediaFiles
|
|
|
|