Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Visual Basic





See Related Forum Messages: Follow the Links Below to View Complete Thread

Fastest Way To Insert A Record Into A Database
Hi,
Im just wondering what is the fastest way to add a new entry into a database.
At the moment im using the .addnew method which I think is the fastest way...however as the database gets much larger the performance of the .addnew method appears to slow greatly.

Also what is the fastest way to search an excel file?

Regards
padraigmc

ADO - Fastest Way To Insert/update Records To Database?
I'm working on a VB6 application that has to quickly insert 32,000 records into a SQL Server 2000 database (connected using ODBC). Using ADO 2.7 I've tried the following:


Code:

First the connection:

Public gcnMain As ADODB.Connection

Dim strConnection As String
strConnection = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=SepsisQStar"

Set gcnMain = New ADODB.Connection
gcnMain.Open strConnection

Then the Insert Statement:

For i = 1 To SpecData.GetNumberOfDataPoints
MoverZ = SpecData.GetDataPointXValue(i)
Intensity = SpecData.GetDataPointYValue(i)
strCom = "INSERT INTO RawData (FileName, FileTimeStamp, SampleName, MOverZ, Intensity) VALUES ('"
strCom = strCom & FileName & "','"
strCom = strCom & FileTimeStamp & "','"
strCom = strCom & SampleName & "',"
strCom = strCom & MoverZ & ","
strCom = strCom & Intensity & ")"
gcnMain.Execute strCom, , adCmdText + adExecuteNoRecords
Next

Alternatively:

'this record will never exist so it opens an empty RecordSet
rsRS.Open "select * from RawData where RawDataID = -1", gcnMain, adOpenForwardOnly, adLockPessimistic

For i = 1 To SpecData.GetNumberOfDataPoints
MoverZ = SpecData.GetDataPointXValue(i)
Intensity = SpecData.GetDataPointYValue(i)
rsRS.AddNew Array("FileName", "FileTimeStamp", "SampleName", "MOverZ", "Intensity"), Array(FileName, FileTimeStamp, SampleName, MoverZ, Intensity)
Next



The For Next will loop about 32,000 times.

In my test environment, both methods take about 5+ mins to do the insert.

Is there anyway to speed this up? Perhaps using DAO or some other database connectivity? Or am I just screwed since I'm hitting a SQL server over the network?

Thanks,

LarsenMTL

Whats The Fastest Way To Insert Text At A Specific Point In A String?
Thisisaverylongstring
How can I insert the word 'THE' at position 9 in this string so it looks like ThisisaveTHErylongstring

Is the fastest way 'newString = left(string, position) & theInsertString & right(string, len(string) - position)

or is there a faster way?

What Is The Absolute Fastest Fastest Way To Add Only Unique Items To An Array?
This array will contain hundreds of thousands of entries.. anyone know what the most efficient way is to add only unique items to that array?

How To Insert Binary Field Using Insert Command In SQL Server
Hello

How can i use Insert SQL command to insert a binary field ?? when ever i send a normal command it gives me an error :"cant convert varcahr into binary, use convert command to convert it explicitly"

my command is:

Insert Into Invoices Values ('12345Jul', '00x00000000')

I am using DataEnvironment.Connection.Execute command to send the insert command. The second field is binary field storing Error Nos.

Any one can help??

Cheers.

The Fastest Way
Hello, ALL!

The question is about Excel.
Who can suggest the fastest way of copying all worksheets from one workbook into another? It is rather slow first to open workbooks then to select all the sheets and then to call the copy method for a workbook. In general I wish to create a new workbook which consists of the sheets taken from several workbooks. Does anybody know maybe there exists good (I mean fast) methods for doing this.

Thanks a lot.

Which Is The Fastest One ?
What is the most speedy and effecient way to populate an MSFlexGrid with Access 2000 SQL query results ?
Thanx

Fastest Way To Do This?
Hey, i'm looking for the best/fastest way to accomplish this:

Here is the scenario

1. have database of 60,000 records
2. i run search and query returns around 6000 records
3. code runs through them and does ranking
4. i only want top 500 records to be inserted into DB.

the way i do it now is:
1. do ranking
2. place item into collection in sorted order (i wrote a small code to insert in proper space)
3. when done ranking. take top 500 from collection and insert into DB

this process takes about 50 seconds to run, and the bottleneck is adding items into sorted collection. how else can i do that?

any help is greatly appreciated

What's The Fastest Way To
dump the entire contents of a SQL server DB into a .mdb?

Fastest Way To Do This?
Hey, i'm looking for the best/fastest way to accomplish this:

Here is the scenario

1. have database of 60,000 records
2. i run search and query returns around 6000 records
3. code runs through them and does ranking
4. i only want top 500 records to be inserted into DB.

the way i do it now is:
1. do ranking
2. place item into collection in sorted order (i wrote a small code to insert in proper space)
3. when done ranking. take top 500 from collection and insert into DB

this process takes about 50 seconds to run, and the bottleneck is adding items into sorted collection. how else can i do that?

any help is greatly appreciated

What Is The Fastest Way To Do This?
I have captured the screen image and put in a picture box set to the size of the screen. I have another picture box that also has a screen image in it. What is the fastest way to compare the 2 pictures against each other pixel for pixel checking for color changes? Also, how would I save that color off? Any code exaples would be great.

Fastest Way ?
Hi,
here's the problem:

I've to fill a combobox with strings. My combo is sorted and I don't want duplicate entries. I check for the strings to be inserted before inserting them. I could loop through all entries in combo for every string I need to insert :


dim x as long
dim MyString as string
dim Found as boolean

found=false
for x=combo.listcount-1 to 0 step -1
if combo.list(x)=MyString then Found=true:Exit for
next x
if found=false then combo.additem MyString


I have to fill my combo with about 10000 names, so this is very slow. I tried a binary search algorithm found here around , but some entries weren't found, producing some duplicates. Now I use an API call:



Const CB_ERR = -1
Const CB_FINDSTRING = &H14C
Declare Function SendMessage Lib "User32" _ Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long

dim MyString as string

if SendMessage(Combo.hWnd, CB_FINDSTRING, -1, ByVal MyString) = CB_ERR then Combo.additem (MyString)



Binary search is faster than that API call? If yes, Can anyone give me a working binary search code?

Best Regards and happy New Year,
Christmas.

What Is The Fastest?
what is the fastest way to populate a treeview control with folders like window explorer?

What's The FASTEST Way To ...
What's the FASTEST way to to get DATA (Binary) from one file, let's say, 2k at a time, manipulate it with whatever, and write that file out to a new file ?

TIA

Is This The Fastest Way?
I am just wondering this because i use code similar to this pretty often. I wonder if there is a faster way to do this. Usually this is okay, but sometimes, instead of a text box, it loops thru 1000 or more strings in a variable array, and is a bit slow.

------------------------------------------------------
Command1_Click
intLength = Len(Text2.Text)
intLength2 = Len(Text1.Text)

If intLength > intLength2 Then Exit Sub
intDifference = intLength2 - intLength

For intNumTimes = 0 To intDifference
strPart = Mid(Text1.Text, intNumTimes + 1, intLength2)
If strPart = Text2.Text Then
MsgBox("String Found")
Exit Sub
End If
Next intLoop

MsgBox("String Not Found")
End Sub
--------------------------------------------------------
Any thoughts?

Fastest Way
What is the fastest way to:
1) Read binary data file to a string buffer
2) Draw that code to picture box?

This is the way I have done it, first the data read and then the drawing:

Seek place, #1
Buffer=input(sizeofbuffer,#1)

For A = 0 to Xsize
For B = 0 to Ysize
Color = RGB(0,asc(mid(Buffer,B*Xsize+A,1)),0
'API call used to draw pixel to the picturebox, can't remember which one
Next B
Next A

Fastest Operator?
I made a timer control that I use in my game engine.
The class has two very useful functions, TimOutA and TimeOutB, both booleans.
The aim is return true wether a certain amount of time has elapsed.
In the TimeOutA function I test using the greater-than-operator ('>')
Eg: If DeltaTime > Delay Then...
In the second, TimeOutB I use the greater-than-or-equal-to operator ('>=')
I implemented both variations thinking that function A might be slightly faster than B, because the egual-to operator must be very precise...
Though it doesn't matter if I do something on the exact time if I know the exact delta time.

So what's fastest? The '>' or the '>='?

Fastest Variable
I know that the Long datatype is 10% - 15% faster than Single, but is it also faster than Integer? Does anybody know where I can find a list of the basic data types, ranked by speed? Thanks.

Fastest Return
which out of these 3 will work the fastest. i am doing a loop backwards till it reaches a number which will divide by 195 equally. they all work but i just want the quickest.

1.

Code:
If InStr(1, i / 195, ".") = 0 Then
2.

Code:
If Int(i / 195) = i / 195 Then
3.

Code:
If i Mod 195 = 0 Then


thanks
thingimijig.

Which Is The Fastest Method...
i have a file with private types inside...which is the fastest way to search in the file? i want to use it like a database...

Fastest IsOdd?
I hear that this is the fastest is odd function:


Code:
Public Function IsOdd (ByRef lngNumber As Long) As Boolean
IsOdd = lngNumber AND &H01
End Function


I hear this one is fast too:


Code:
Public Function IsOdd(ByRef lngNumber As Long) As Boolean
Dim lTemp As Long
lTemp = CLng(Right$(lngNumber, 1))
If lTemp <> 0 Then
If lTemp <> 2 Then
If lTemp <> 4 Then
If lTemp <> 6 Then
If lTemp <> 8 Then
IsOdd = True
End If
End If
End If
End If
End If
End Function


Which one is fastest?

Fastest Access
Pardon the pun but I would like advice on how get at data in an Access database in the fasted possible manner. The database has one table and that table consists of a primary key string and a Description memo field. Each record in the table will be unique and I just need to be able to read a record, possibly update it or at other times add a new record.

Find Age Is This Fastest?
Anybody know if there is another way or faster way to calculate age on a given date I have:


Code:
Function GetAgeOnDate(DOB, CurrentDate As Date) As Byte
If IsNull(DOB) Then
GetAgeOnDate = 0
Else
GetAgeOnDate = DateDiff("yyyy", DOB, CurrentDate)
If CurrentDate < DateSerial(year(CurrentDate), month(DOB), day(DOB)) Then
GetAgeOnDate = GetAgeOnDate - 1
End If
End If
End Function


I didn't set a variable type for the input DOB because it failed on null values I think but it was a while back. Is there a variable type I could use or a more efficient way to do this.

Thanks in advance

How Would I Go About Getting Many Sources? (fastest)
Basically, I want to leech source code of (lets just say) 100 sites.

As each page is leeched I want to parse it on the spot.

So, for each site I would basically:
1. Request the page (get the source code).
2. Parse it.
3. Organize that information into variables.

What way should I go about doing this, if I want to create multiple connections? Let just say I choose 10 connections... Id want all 10 of those doing steps 1, 2, and 3 independently from the other connection...

This way, the whole process wont be linear. And if one site is slow on the reply, or slow dl, there multiple connection will insure this whole process is done as fast as possible.

I am looking for the fastest (download) way to do this, while also being reliable. <- Speed is important.

What Is The Fastest Way Of Getting An Ip From A Domain?
ie, if you tell winsock to connect to www.google.com, it automatically knows to connect to 66.102.7.104

how does it know?

Fastest Encryption
Hi, I would like to know what is the fastest encryption available, but I don't want it to be intensively secure. I just want something illegible to the human eye. For example, letter key shifting doesn't work because it's easy to visualize what the words were before hand. I just need something that you can't just crack by staring at it for 10 seconds, but it can't be resource intensive or slow. Any ideas?

Fastest Way To Open TXT ??
Hi All !

What is the fastest way to open a TXT as ReadOnly ?
Open "" as #1 ?
FSO ?

The TXT has about 11Mb, and is being added line by line during the day. That is why I need it to be read-only and doesnt stop the other process.
Imagine this, during the day, a program keeps adding lines to a TXT and I need to get the from minute to minute....

What do you recommend ??
Any help is appreciated !!


THANKS !!!!
Martin.

Fastest Way To Delete?
Hi folks,

I am using the follwoing code send files to recycle-bin:


VB Code:
Public Function SendToRecycleBin(sFilePath As String) As Boolean    On Error Resume Next        Dim SHFileOp As SHFILEOPSTRUCT        With SHFileOp        .wFunc = FO_DELETE        .pFrom = sFilePath & vbNullChar        .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION    End With        SendToRecycleBin = (SHFileOperation(SHFileOp) = 0)End Function


This code sends the file to recycle-bin, but it is very sluggish. Can any one suggest a faster way?

Thanks.

Fastest Way To Take A Screenshot????
Does anyone one know what the quickest way to take a screenshot would be?

My program takes a screenshot of another computer and has it sent over winsock

I use the vbkeysnapshot event but it seems that over time, it takes longer and longer to process the screenshot it takes sometimes over 10 seconds just for the screenshot to happen, then it takes another 5 or 10 to send it over winsock

Anyone have a faster way to take a screen shot?

Justin

VB Loops... Fastest Typ?
Which is the fastest executing VB loop construct? Do you have a favourite?

Which Loop Is The Fastest?
Is this a proper way to test loops? I read somewhere that For Loops are the fastest out of all loops.


Code:
Dim sTest As String
Dim lC As Long
Dim lCurrentTime As Long
lCurrentTime = Timer
For lC = 1 To 100000
sTest = lC
Next
MsgBox Timer - lCurrentTime, vbOKOnly, "For Loop"

lC = 0
lCurrentTime = Timer
Do
lC = lC + 1
sTest = lC
Loop While lC > 100000
MsgBox Timer - lCurrentTime, vbOKOnly, "Do While"

lC = 0
lCurrentTime = Timer
Do
lC = lC + 1
sTest = lC
Loop Until lC = 100000
MsgBox Timer - lCurrentTime, vbOKOnly, "Do Until"

Which Is The Fastest Loop
which is the fastest way to loop throoug over 33000 values shall i make a for for it ?

Code:
for i=0 to 33000
next i

or what?

thnks

Help! I Need Fastest 3D Algorithms
I am doing a 3D engine using QuickBasic and I need the fastest 3D algorithm around! Including calculating vertexes, texture mapping, affine mapping, and if not too much asking, raytracing algorithms.
I've did a search but no luck.
Hope you guyz will help me!
Thanks

Who Is The Fastest To Answer This?
How does one check a server's system date instead of checking the client's system date in .ASP?

I realize Now() checks the client's system date but I need to base my application off of the server it is running on.

Fastest API To Get A Pixel, And Set One?
Hello.

What are the API declarations for the
fastest ways to set a pixel and to get
a pixel?

Witch One Is The Fastest
What is the fastest

Do while x = 100
x=x+1
Loop

or

For x = 0 to 100
Next

Is it the same in ASP

Or is there a faster way??

Fastest Convert To Png
I'm looking ofr the fastest VB-callable library to capture the screen and
convert to png, preferable without writing to a disk file.

Of course, I can also do the capture myself and call a routine, but I need
the fastest one. Does anyone have any ideas?



Brad Jensen

Fastest Execution For DML S
All of we kno that we can perform ANY DML operation using either of connection , command , recordset obj in case ADO object.
i want to know which of is fastest in case of performance. i.e. is connection.execute method is fase or command object method ( that i never used ) or rs.update method .



It May seem Impossible, But Possibly We don't know the way how to reach there ????

Insert Sql Wont Insert Data After Decimal
i have a form that uses a Calculation script to do the vat calculation

Code:Option Explicit ' Requires variables to be declared before they are used

Rem * Declarations ***********************************************************
Dim dblNumber As Double 'Number Entered by user
Dim dblResult As Double 'Result of calulation
Dim intOption As Integer 'Operator held (+,-,*,/)
Dim dblMemory As Double 'Number stored in the Memory
Dim blnOption As Boolean 'Number","+","."
Dim blnEqual As Boolean 'Equals error
Dim blnMemory As Boolean 'Memory error
Dim blnError As Boolean 'If Point '.' is press more than once
Dim strVat As String 'VAT user number entered
Dim dblTotal As Double 'VAT Total
Dim strAnswer As String 'VAT Answer


Public Sub VATCALC()
On Error Resume Next

dblTotal = (Invoicesto.Price.Text * Invoicesto.Vatpc.Text) / 100 '* strVat '(txtSubTotal.Text * 17.5) / 100

Invoicesto.exvat.Text = Invoicesto.Price.Text - dblTotal 'Round(strAnswer, 2)
End Sub

 VATCALC works, however when i add the product to the table the calulations have no decimal and data after it.

Fastest Way To Search A File
First off, I searched, but couldn't really find what I'm looking for.

I'm writing a program that streams videos, but I need it to detect where the frames end so I can send it out at the right speed.. The frames are separated by the ascii NSVs or by the hex BEEF (EF BE). The way I have it setup now is it opens the file in binary. In a loop, it'll GET a byte, check it for N or the hex of BE. If one of those is met, it'll check for the S or BE and so on. This goes a few KB per second, but I need it to go faster (some videos are upwards of 60-70 KBps)

Can anyone help? TIA

Fastest Way Of Reading A File
I've tried opening files using Open and Get but it takes around 2 minutes to open a 100 mb file. Is there any way using VB to open a file in binary mode that ranges from 100mbs to 200mbs within 5 seconds?

AlphaBlend Chart - Fastest Way ?
Guys,

Need a pointer or two for creating a chart control. What I want to be able to do is draw lines and filled regions (with alphablend effect) with the possibility of removing some lines/regions (and therefore returning the underlying alpha values to what they were). What would be the best (fastest) method for doing this. my initial thoughts:

1. Using API to draw onto MemDc's, then using AlphaBlend API function to blend the two 'images' (lines/regions effectively). Would I need to use the TransparentBlt function before blending ?

2. Using pointers for Direct Memory Access, thereby drawing pixel-by-pixel and undertaking per-pixel alpha.

What are your opinions on each of the above - generally and in terms of speed ? Also, with option 1. if I wished to remove one line/region from the image, presumably, I would only accomplish this by removing the required line/region from a collection and 'redrawing' the remainder ? This sounds quite time consuming - Is there not a way to 'reverse alpha' ??

Thanks in advance for any and all comments.

Fastest Way To Search And Compare
My old thread died because I couldnt really describe my problem and what I wanted to do, ive tinkered around somemore with this but I can simply not get it to work with any decent speed.

The program is for an online game and its for comparing statistics of different items.
Each character have four different itemslots to equip and what im trying to do is to compare each and every combination of those four item types. So if I want to know what combinations give lets say attack >30 I compare all items to each other and sort out the ones that together add upp to attack >30.

The database will be distributed with the program so its all local, no server traffic to take into account.

So far im just using a simple db I created in Access, but I get horrible speeds looping through all the different items.
Each category has appx 90 items in it, 90*90*90*90=65610000 combinations and simply looping through is just way, way to slow.

Any suggestions on how to solve this problem, perhaps a whole different type of database and approach?

Fastest Code Execution?
Assuming your application needs to execute code as quickly as possible, which of the following 2 examples would be most efficient?

A is the "On/Off" switch so the other 2 conditions are subordinate to A.


Quote:




Eg1/

If A=True And B=True And C=True then run_procedure





Quote:




Eg2/

If A=True then

If B=True And C=True then run_procedure

End If

What's The Fastest Way To Draw A Line?
Just on a form, and without using anything like DirectX. Is the Form.Line method just as fast as any API method(s) that will do the same?

Fastest Way To Capture Screen
Hi,

I am currently trying to capture the desktop the fastest way possible. I am using Bitblt to place a screen capture in a picturebox, that works fine but when I try to save the picturebox.picture as a file i get nothing. For some reason the picturebox.picture is returning a 0 even though I can see it. I have previously used the print screen/clipboard method but it is too slow for the purpose of the app.

Any ideas at all much appreiciated,

Regards
Ross

Fastest Bindable Listview?
Who makes the fastest bindable listview control?

I have a SQL server database and I'm going to need a listview control that can display about 3-4 columns of information fast. The data source will be the result set of a stored proc in sql server. Could be as many as 10000 records coming back. So I guess something uses a 'virtual' mode??

I don't need fancy stuff, just speed, and ease of use.

Fastest Possible DataType Conversation
I'm trying to write a MMORPG class server in VB and my goal is to maximaze the ammount of player it can handle.Since packet processing is currently talking the most cycles, I noticed that it could be optimize considerably by processing the packet from a binary array instead of a string.

My problem is that I need the fastest way to convert a certain part of my binary array to a string. For exemple Each () is 1 byte: (PacketHeader)(PacketInfo)(StrLenght)(Str1Char1)(Str1Char2)...(Char500 )
Now let's say my string start at 4 and it 500 characters long. What is the fastest way to convert this data, starting at byteArray(4) until (504)?

I need to be able to place Currency, Long, Str data type into and be able to Convert them out of my array. The problem is that only certain part of the array represent a certain datatype, then after it might represent something else.

As far as my knowledge goes, CopyMemory is the fastest way to convert data from one location of the memory to another. Is it possible to use it to convert from a certain position in my array to another to a certain datatype and place a certain datatype at the end of my byteArray?

Thanks a lot for your help!

Fastest Filcopy Discussion
Hi coders,

I am wanting to discuss your thoughts on which file copy method is fastest and why. I have been piecing together a file copy program based on some needs in our production department and have completed it for the most part. the only thing they dont like is the speed of the copy. For instance they needed to copy 500,000+ files. They had the filepaths in a file so all i had to do was read the path and copy that file to a path. No big deal really. I used the copy ShellFileCopy API. It worked fine with a few excptions which I might talk about later. But I really wonder what you other coders felt was the most efficeint method to use when copying files.

Guy

Copyright © 2005-08 www.BigResource.com, All rights reserved