|
I am working on a customized Excel VBA function. I have developed a two dimensional array consisting of two fields. The first element is a Date field and the second field is an Integer field. The problem is that now I need to search through the array using the first field, and when a match is found to return the second field as the result. The name of the array is arrArray. It is a static array with a set number of records. How should I go about searching the array?
As an example, let us assume that there are ten elements and that they are properly loaded like this:
Dim arrArray(10, 1)
arrArray(#1/1/2006#, 1)
arrArray(#1/2/2006#, 4)
How do I search through the first element field for a match, and when a match is found to return the second element?
|
|
|
|
|
Assuming you have filled the array with something like:
arrArray(1, 0) = "#1/1/2006#"
arrArray(1, 1) = 1
arrArray(2, 0) = "#1/2/2006#"
arrArray(2, 1) = 4
Then something like this should do it
Dim retVal
Dim match
Dim i
match = "#1/2/2006#"
For i = 1 To 10
If arrArray(i, 0) = match Then
retVal = arrArray(i, 1)
End If
Next i
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Hello All,
Problem:
I've a table which has dynamic columns, I dnot know how many they are becasue they are created dynamically.
Now I've to insert some of columns to other table.
But I'm unable to find the way to fetch the columns by index.
I want to use like this,
<br />
insert into tbl(TableName.Columns[0].Name,TableName.Columns[2].Name,.....,TableName.Columns[n].Name)<br />
values (TableName.Columns[0].Value,TableName.Columns[1].Value,.....,TableName.Columns[n].Value)<br />
Plz Help
Thanks
Syed Shahid Hussain
|
|
|
|
|
The following query returning the following result:
SELECT count(*) FROM `table1`;
--------------------
Resilt 2000
But the following Query returning different result
SELECT
table_name,
table_rows AS rows
FROM information_schema.tables
WHERE table_schema = 'bakrol14' and table_name = `table1`
Order by table_name;
--------------------
Result 2143
What is the reason?
|
|
|
|
|
|
hi all..
here is my problem:
DECLARE @RETURN1 FLOAT
SET @RETURN1 = 1234.12345
select ROUND(@RETURN1,4)
--*returns : 1234,1235
DECLARE @RETURN2 FLOAT
SET @RETURN2 = 12345.12345
select ROUND(@RETURN2,4)
--*returns : 12345,1234
DECLARE @RETURN3 FLOAT
SET @RETURN3 = 1234567.12345
select ROUND(@RETURN3,4)
--*returns : 1234567,1235
as you see above; when the length of digits leftside of the point is 4 it rounds up to #,1235.. but when length of digits is 5 it rounds down to #,1234 and when length is 7 it again rounds up to #,1235
whats wrong with that?
anybody has an explanation_?
|
|
|
|
|
Take a look at this document.[^]
Which result you want to get after you execute those querys?
From 1234.12345 you want to get 1234.1234 ?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
It is a float type conversion problem. Try using a wider data type. (use decimal with appropriate parameters)
|
|
|
|
|
|
if application use sqlapi to connect(remotely) to mysql/sql server at startup, then while application is running if mysql/sql service is restarted then connection will lost(execute() function of sqlapi says connection is lost).
But isconnected() and isalive() functions of SAConnection class in
sqlapi tells connection is not
lost. then how to know if connection is lost by which function?
|
|
|
|
|
Hi All
I am working on a vb 6.0 + MySQL project.
I need to create a Database(for local use Ex:- If user wants to create database they can create and dump data from online databas) Dynamically and restore the database with production database backup.
Is it possible?
Thanks,
Willington D
|
|
|
|
|
You are also cross posting.
Bad enough you want to use a dead platform to build on, now you want to cross post as well. Will you please move into the 21 century and use VB.net - it's FREE and you'll get much more support from the forums.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes it is possible. Use the ODBC driver for VB6 via a DSN and issue commands through ADO. Look-up the syntax on the MySQL website for CREATE DATABASE databaseName and associated admin functions.
|
|
|
|
|
how to get number of tables in MS access
|
|
|
|
|
Use the following in the Query Sql design view.
SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Flags)=0) AND ((MSysObjects.Type)=1))
ORDER BY MSysObjects.Name;
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
Hi
i have some tables in my database like this :
Table1
Table2
Table3
each record of each table can have one or more images, hence i need a Table to hold only images and parentId field, but my problem is that how can i create a one table to hold images of all tables and have relationShips with other tables ?
what's your idea ?
Note :
1. In webSite db i use sql server, but in client db, i use Access 2007, hence i can't use trigger.
2. I don't want to search tablles, because it's performance is very slow.
3. i can't merge tables because table structures is different.
Thanks
|
|
|
|
|
New table fields are
TableName
IDValue
Image
Problem is you cannot set up relationships, you can NEVER setup relationships when you move the structure into your data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi guys....
i have this table
ID_____NAME______OTHER_____
1_____Name 1__First value
2_____Name 2__Second value
3_____Name 2__Second value
4_____Name 2__Second value
5_____Name 2__Second value
6_____Name 3__Third value
7_____Name 3__Third value
8_____Name 4__Fourth value
i need to make SQL query wich will eliminate all duplicates from table (all fields are comparing, except id) but one.
for example, after query is executed table should look like this:
ID_____NAME______OTHER_____
1_____Name 1__First value
2_____Name 2__Second value
6_____Name 3__Third value
8_____Name 4__Fourth value
any help appreciated...
|
|
|
|
|
Are you using Microsoft SQL Server?
If yes, you could use the following query (you have to adopt it to your db):
;WITH MyTable_CTE(Name, Ranking)
AS
(
SELECT Name,Ranking = DENSE_RANK() OVER (PARTITION BY Name ORDER BY NEWID() ASC)
FROM MyTable
)
DELETE FROM MyTable_CTE
WHERE Ranking > 1
Hope this helps
Regards
Sebastian
|
|
|
|
|
I have this code written in PERl to connect to a MS-Access-2007 DB .
But my output does not print any of the contents. Could anybody figure this out?
use Win32::ODBC;<br />
$DB=new Win32::ODBC("perlDSN");<br />
if($DB->Sql("select no,cname from tab1"))<br />
{<br />
printf("Error reading\n");<br />
exit;<br />
}<br />
while ($DB->FetchRow())<br />
{<br />
($a,$b)=$DB->data();<br />
print("We have $a\n");<br />
}
|
|
|
|
|
hello every one
i m having error of converting datatype varchar to numeric while inserting
my query is
insert into des_mast (des_name,des_numb,des_recno.....)values('"me.textbox1.text"','"+me.combobox1.text+"','"+me.textbox2.text+"'.....)
and so on there are around 20 such fields in data base and all these fields like des_name,des_numb are set to allow null property.
now if i insert each and every values of textboxes and comboboxes at runtime there is no error of such type and query runs perfectly
but if i keep some textboxes or comboboxes with blank text this error is seen...
"Error converting data type varchar to numeric."
so please suggest what shall i do..
thank you in advance..
Smile Smile Smile
|
|
|
|
|
You are trying to convert and empty string '' to a numeric value, this cannot be done. I suggest you default the value of numeric textboxes to '0'
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi
u suggested to place default value of textboxes to '0'
but there are many such textboxes where there values are in nvarchar()
so if i place values to '0' it will create problem
and on this there are such around 30-35 such textboxes and comboboxes placed
i tried something like
insert into des_mast(pincode)values('"+ctype(me.txtpincode.text,integer)+"') there are such columns round about 30-35 in database this is just an example
but it too showed error message like:-"Conversion from string "','" to type 'Double' is not valid."
so please suggest some another way.
|
|
|
|
|
You have little choice in the matter, you need to give the database the correct datatype otherwise you are going to get an error!
Either manage your data or quit, there are many ways and places to set the default values, textboxes, method that reads the textboxes, stored proc that processes the data etc.
It's all about designing your application, currently you have a crappy design, you need to fix it. You know the cause of the problem it's your data so fix it!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
As Mycroft says
I think the problem is when you try to insert "" in a numeric column, "" is not NULL
Besides, take care of sql injections, since you are concatenating strings
You shouls use sqlparameters, and there you can set a default value, as well as a condition to set empty string "" to null (At least in asp.net, i havent done it in windows forms, but it must be posible)
Alexei Rodriguez
|
|
|
|