|
Try using the Execute method of the dataabse object instead of the OpenRecordset method.
db.Execute(SQLString)
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Will give it a try...
Thanks
I was born intelligent Education ruined me!.
|
|
|
|
|
I can pass an ArrayList of myClassObjects to a DataGrid and it obligingly displays it but it shows all of the Columns at the default Width including the ID Column. It also labels the Columns with myVariable names.
myDataGrid.DataSource = myClass.myFunction
Where myFunction is returning an ArrayList of MyClassObjects.
I have tried using a DataGrid Table Style Object etc. to no avail. How can I hit those pesky Column Objects directly to set their Widths and Headings?
|
|
|
|
|
How do I check if the logged onm user is an administrator in VB.Net?
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Try something like:
Imports System.Security.Principal
...
Dim identity As WindowsIdentity = WindowsIdentity.GetCurrent()
Dim principal As New WindowsPrincipal(identity)
Dim isAdmin As Boolean = principal.IsInRole(WindowsBuiltInRole.Administrator)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hi....
How do I set the number of lines in a RichTexxtboxControl or limmit the number of lines?
/Fleischen
|
|
|
|
|
Hi...
I am a beginer to VB.. and a basic question....
Any code or snippet for accessing MS access database from VB, on a button click action... I tried this....
Private Sub Command1_Click()
Dim DBCon As ADODB.Connection
Dim rsTemp As ADODB.Recordset
Dim objMail
Set DBCon = New ADODB.Connection
Set rsTemp = New ADODB.Recordset
On Error GoTo errhandle
DBCon.Open dsn.Text, username.Text, password.Text
rsTemp.CursorLocation = adUseClient
rsTemp.Open SQLstr.Text, DBCon, adOpenForwardOnly, adLockReadOnly
mailbody = body.Text
For i = 1 To CInt(paramnum.Text)
mailbody = Replace(mailbody, "[x" & i & "]", rsTemp.Fields("x" & i))
Next i
MsgBox "From = " & from_txt.Text & Chr(10) & Chr(13) & _
"To = " & rsTemp("toemail") & Chr(10) & Chr(13) & _
"Subject = " & subjfield.Text & Chr(10) & Chr(13) & _
"Body =" & mailbody
Exit Sub
errhandle:
MsgBox Err.Description
End Sub
But it says....
Compile Error, User defined type not defined in the very first line of the code. Should I make/modify any configurations??
Thanks
I was born intelligent Education ruined me!.
|
|
|
|
|
Did you add Microsoft ActiveX Data Objects to your references? To do this, Click Project | References on the menu, and check the check box beside it in the dialog box.
Do unto others as you would have them do unto you - Jesus
An eye for an eye only makes the whole world blind - Mahatma Gandhi
|
|
|
|
|
jdunlap wrote:
Did you add Microsoft ActiveX Data Objects to your references?
Ahhh!! I didnt do it... Thanks....
I was born intelligent Education ruined me!.
|
|
|
|
|
I am trying to watch for "n" number of folders. Do I have to create "n" number of FileSystemWatcher instance to do this? If anybody worked on this please advice. Thanks a lot.
Zulfikar Ali
|
|
|
|
|
Is more easy create one folder and five subfolders. You only watch for the parent folder or root folder and FilSystemWatcher, with "true" in watch subdirectories option, watch the six folders.
Victor
|
|
|
|
|
Thanks for your reply. But folders can't be sub folder in my project. Anyway i have figured out the solution. Here is the code if anybody is interested.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
Dim strName As String
Dim strDBReject As String
Dim strParseReject As String
'Load the profile info from the setup XML file
Dim dsGetIni As New DataSet()
dsGetIni.ReadXml(Application.StartupPath & "\setup.xml")
Dim dtGetIni As DataTable = dsGetIni.Tables("Profile")
i = dtGetIni.Rows.Count
Dim objRow As DataRow()
For i = 0 To dsGetIni.Tables("Profile").Rows.Count - 1
strName = dtGetIni.Rows(i)("Name")
strDBReject = dtGetIni.Rows(i)("DBReject")
watcher(strDBReject)
strParseReject = dtGetIni.Rows(i)("ParseReject")
watcher(strParseReject)
Next
End Sub
Public Function watcher(ByVal strFolder As String)
Dim objWatcher As New System.IO.FileSystemWatcher()
'Folder to watch
objWatcher.Path = strFolder
'File extension to watch
objWatcher.Filter = "*.pdf"
'Create delegates to handle the events for the FileSystemWatcher
AddHandler objWatcher.Created, AddressOf OnFileCreated
'Exclude subdirectories from watching
objWatcher.IncludeSubdirectories = True
'Start watching folder
objWatcher.EnableRaisingEvents = True
End Function
Public Sub OnFileCreated(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
Try
'create new instance of importer
Dim FileInfo As New FileInformation(e.FullPath)
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf ProcessFile), FileInfo)
Catch ex As Exception
End Try
End Sub
Private Function GetExclusiveAccess(ByVal FilePath As String) As Boolean
Try
Dim theFile As File
Dim strm As Stream = theFile.Open(FilePath, FileMode.Open)
'if we succeed, we can let it go
strm.Close()
GetExclusiveAccess = True
Catch e As Exception
GetExclusiveAccess = False
End Try
End Function
Public Sub ProcessFile(ByVal fileInfo As Object)
If Thread.CurrentThread.Name = "" Then
Thread.CurrentThread.Name = Thread.CurrentThread.GetHashCode().ToString
End If
'try to get exclusive access to the file first
Dim i As Integer
For i = 0 To 30
If GetExclusiveAccess(fileInfo.filepath) Then
Exit For
ElseIf i = 30 Then
Exit Sub
End If
Thread.Sleep(5000)
Next
Dim strFilePath As String
Dim strFileName As String
Dim strDirName As String
Dim strVendorName As String
Dim strReason As String
Dim x As Integer
Dim y As Integer
strFilePath = fileInfo.filepath
strFileName = Mid(strFilePath, InStrRev(strFilePath, "\") + 1, Len (strFilePath) - InStrRev(strFilePath, "\"))
MsgBox(strFilePath)
'Add Reject file info to the database
addtodb(strFileName, strVendorName, strFilePath, strReason)
End Sub
If anybody is interested try this code. Let me know if you have any questions. Thanks
Zulfikar Ali
|
|
|
|
|
Hi...
How do Change the location of, for example a textbox? I Know u Can do it when you place the textbox. But if you wat to do it during runtime, how do u do it?
Code used:
TextBox1.Location.X = 10
Error message:
Expression is a value and therefore cannot be the target of an assignment.
/Fleischen
|
|
|
|
|
Fleischen wrote:
How do Change the location of, for example a textbox? I Know u Can do it when you place the textbox. But if you wat to do it during runtime, how do u do it?
Change the .Left and .Top values.
-Nick Parker
|
|
|
|
|
Hello Everybody,
I am developing a Module in which I suppose to use Web Browser control which acts as Windows Explorer. I am tried most of the functionality with SendMessage API with different parameters like IDM_SHVIEW_LARGEICON, IDM_SHVIEW_SELECTALL etc.
But now I want to create a New Folder in the exact way Windows Explorer allows user. For consideration, let's say we will click a button & New Folder functionality should work. All the mention parameters are working with SendMessage API except IDM_SHVIEW_NEWFOLDER.
'Declaration
Private Const IDM_SHVIEW_NEWFOLDER = &H7261
'In command button
SendMessage(hwndSHView, WM_COMMAND, IDM_SHVIEW_NEWFOLDER, 0)
' hwndSH = handle of the SysTreeView32
' WM_COMMAND = message
' IDM_SHVIEW_NEWFOLDER = lParam for action to be performed
' 0 = wParam
I cross check the window's handle value. Still not getting the result. Also assigned handle the default value (which I got from SPY++).
Please please please help me out from this problem.
Regards,
Vilas
|
|
|
|
|
dear all
how do i execute dos commands like "net send" and deltree from vb
thanx and regards
rishabhs
|
|
|
|
|
Shell or ShellExecute API
Not all those who are lost are looking to be found. But of those who are lost and those who are found, all are looking for something higher than themselves.
|
|
|
|
|
do you have access to SQL Server or MSDE ??
if yes try this in a stored procedure..
declare @command varchar(1000)
-- delete a file on the C drive
SELECT @command = 'del C:\Test.txt'
-- execute DOS command
master.dbo.xp_cmdshell @command
that should do it
|
|
|
|
|
Ok, I need to know how to Convert a Number to a BIG/LITTLE ENDIAN Number and also how to do "Left / Right Shifts" (i.e. in C++ / C# "5 << 16") in VB.NET or VB6. Anyone know how?
|
|
|
|
|
Hi,
Read this aticle of new version of VB.NET 2003, "Shifting to the Left or the Right" point:
http://msdn.microsoft.com/library/en-us/dv_vstechart/html/vbconVisualBasicNET2003LanguageChanges.asp?frame=true#vbconvisualbasicnet2003languagechangesanchor4
"On the 8th day, God started debugging"
|
|
|
|
|
Here's your VB6 code:
'MakeDWord
'MakeWord
'HiByte
'LoByte
'HiWord
'LoWord
'RShWord
'LShWord
'LShDWord
'RShDWord
'DWordWSwap
'WordBSwap
'ToggleBit
'SetBit
'ClearBit
'SetBitVal
'IsBitSet
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
'BBBB Y Y TTTTT EEEEE
'B B Y Y T E
'BBBB Y T EEEEE
'B B Y T E
'BBBB Y T EEEEE
'***************************
'Extract
'*********
Function LoWord(ByVal dw As Long) As Integer
CopyMemory LoWord, dw, 2
End Function
Function HiWord(ByVal dw As Long) As Integer
CopyMemory HiWord, ByVal VarPtr(dw) + 2, 2
End Function
Function LoByte(ByVal dw As Integer) As Integer
CopyMemory LoByte, dw, 1
End Function
Function HiByte(ByVal dw As Integer) As Integer
CopyMemory HiByte, ByVal VarPtr(dw) + 1, 1
End Function
'Swap
'*****
'(Little <--> Big Endian)
Function WordBSwap(ByVal Wd As Integer) As Integer
WordBSwap = MakeWord(HiByte(Wd), LoByte(Wd))
End Function
Function DWordWSwap(ByVal dw As Integer) As Integer
DWordWSwap = MakeDWord(HiWord(dw), LoWord(dw))
End Function
'Bit Shift
'**********
Function LShWord(ByVal Wd As Integer) As Integer
LShWord = MakeWord(HiByte(Wd), 0)
End Function
Function RShWord(ByVal Wd As Integer) As Integer
RShWord = MakeWord(0, LoByte(Wd))
End Function
Function LShDWord(ByVal dw As Long) As Long
LShDWord = MakeDWord(HiWord(dw), 0)
End Function
Function RShDWord(ByVal dw As Long) As Long
RShDWord = MakeDWord(0, LoWord(dw))
End Function
'Create
'***********
Function MakeWord(iLo As Integer, iHi As Integer) As Integer
CopyMemory MakeWord, iLo, 1
CopyMemory ByVal VarPtr(MakeWord) + 1, iHi, 1
End Function
Function MakeDWord(iLo As Integer, iHi As Integer) As Long
CopyMemory MakeDWord, iLo, 2
CopyMemory ByVal VarPtr(MakeWord) + 2, iHi, 2
End Function
'BBBB IIIII TTTTT
'B B I T
'BBBB I T
'B B I T
'BBBB IIIII T
'***************************
Sub SetBit(refByte As Integer, Bit As Integer)
' Create a bitmask with the 2 to the nth power bit set:
Mask = 2 ^ Bit
' Set the nth Bit:
refByte = refByte Or Mask
End Sub
Sub ToggleBit(refByte As Integer, Bit As Integer)
' Create a bitmask with the 2 to the nth power bit set:
Mask% = 2 ^ Bit
' Toggle the nth Bit:
refByte = refByte Xor Mask%
End Sub
' The ClearBit Sub clears the nth bit (Bit%) of an integer (Byte%).
Sub ClearBit(refByte As Integer, ByVal Bit As Integer)
' Create a bitmask with the 2 to the nth power bit set:
Mask% = 2 ^ Bit
' Clear the nth Bit:
refByte = refByte And Not Mask%
End Sub
Sub SetBitVal(refByte As Integer, ByVal Bit As Integer, ByVal Value As Boolean)
Mask% = 2 ^ Bit
If Value Then _
refByte = refByte Or Mask _
Else _
refByte = refByte And Not Mask%
End Sub
Function IsBitSet(refByte As Integer, ByVal Bit As Integer) As Boolean
' Create a bitmask with the 2 to the nth power bit set:
Mask% = 2 ^ Bit
' Return the truth state of the 2 to the nth power bit:
IsBitSet = ((refByte And Mask%) > 0)
End Function
Do unto others as you would have them do unto you - Jesus
An eye for an eye only makes the whole world blind - Mahatma Gandhi
|
|
|
|
|
Thanks! Good functions!
Basically I wanted to know how to "Left / Right Shift" a number but the above functions will also come in handy. I will Post here how to do Shifts.
To Right Shift, simply Divide by (2 ^ [No of Bits]). For example, to Right Shift 16Bits:
Public Function ShiftRight(ByVal Value as Long) As Long
Return (Value / (2 ^ 16))
End Function
To Left Shift, simply do the opposite and Multiply by (2 ^ [No of Bits]).
Public Function ShiftLeft(ByVal Value as Long) As Long
Return (Value * (2 ^ 16))
End Function
The good news is that in VB.NET 2003, the Left / Right Shift operators will become standard. So now the above Functions would be simplified like this:
Public Function ShiftLeft(ByVal Value as Long) As Long
Return (Value << 16)
End Function
Of course, you really wouldn't need a Function for it anymore in .NET 2003!
|
|
|
|
|
Glad you like them! That is the cByteFns class from my Data dll.
Do unto others as you would have them do unto you - Jesus
An eye for an eye only makes the whole world blind - Mahatma Gandhi
|
|
|
|
|
I know MS (FINALLY) added in lazy evaluation versions of And (AndAlso) and Or (OrElse). Have they perchance introduced a lazy eval version of the ternary-operator function (Iif)?
Thats one thing i sorely miss from the C/Java world is the nice ?: operator. Iif can sort of emulate it, but Iif always evaluates both conditions (true AND false)... where as the ?: one only evaluates which ever one is selected by the condition. The Non-Lazy Iif is all but useless for the most very simplest simplest basic cases.
Thanks in advance
|
|
|
|
|
Whosit wrote:
Thats one thing i sorely miss from the C/Java world is the nice ?: operator. Iif can sort of emulate it, but Iif always evaluates both conditions (true AND false)... where as the ?: one only evaluates which ever one is selected by the condition. The Non-Lazy Iif is all but useless for the most very simplest simplest basic cases.
I suspect Iif is implemented as a function. See, the worst thing about Iif is that it return an object, and if Option Strict is On, you'll need to cast, even if both types are correct.
It's not the fall that kills you: it's the sudden stop - Down by Law, Jim Jamursch (1986)
|
|
|
|