|
Chrissy Callen wrote:
listitems.subItems.Add(IIf(IsDBNull(.GetString(1)), .GetString(1), ""))
This statement is sitting inside a 'With' block. It would help to know what that 'With' is.
The GetString Method is being executed on a record that doesn't have a value. What you should be checking for first is if there is a value there, then execute GetString on it. Your trying to see if GetString returns a NULL, and if true, return the GetString NULL, if false, return an Empty string.
What you should be doing is this:
IIF( expression, Object if expression True, Object if expression False ) As Object
listitems.subItems.Add( IIf( IsDBNull(<whatever'With'Is>), "", .GetString(1) ) )
RageInTheMachine9532
|
|
|
|
|
It has to do with the IIf statement. It evaluates both conditions, regardless of whether the first one is true or not. In other words, it does not short-circuit. You need to use the regular VB If-Else-End If construct to make this logic work the way you want.
|
|
|
|
|
Hi
First sorry because my english is not very good.
I am a vb.net beginner , later I work with Visual C++.May be my problem is funny or maybe the datagrid is not a standard tool to work with data(add,remove,update,...) but I really have lots of problem with it.
I want to design a form that user should enter many records and at a time see the previous and next records.This Table has many fields I think it must be easier for the user to enter some of the fields in the columns of the datagrid and some of it in the form(textbox,combo,..) below the datagrid. and also some of the datagrid should be like combo box and some of it textbox and some of it Timeformat.I can connect the datagrid to the base and read the data . but I have not any control on the DataGrid,for example set a special query or change the column appearance to combo box or Mask edit or tabbed from one row of the column to the fields of the form for entering another fields of the record.how can I do these?
Can I use Ado not ado.net with VB.Net dataGrid ? if I can use ado and set the columns of the datagrid to the ado recordset it's so better.if I can do it please tell me how?Thanks a lot
|
|
|
|
|
Other than Source Safe, what version control systems have you used? Also, did they integrate with VB6, VS.NET? We are a very small company, and the cost of source safe is a big hit for us. Is there anything cheaper, as stable, as integrated?
Thanks.
Nursey
|
|
|
|
|
I have used CVSNT (www.cvsnt.org) with the TortoiseCVS client for a few months. But during this week I've changed to Subversion (subversion.tigris.org) with the TortoiseSVN client.
CVS is an older system very well known for Unix users and CVSNT is the Windows version of that system. As for Subversion, is targeted to replace CVS in the next years and from what I have seen they have a very good chance of doing just that.
Both Tortoise clients work in the same way. They are integrated in Windows Explorer and with just a few clicks you can do whatever you want with them. There are more clients around but those are the ones I like the most.
Both systems and clients are 100% free and they have worked very well for me with WindowsXP and .NET projects. I haven't found a reliable client to use CVSNT or Subversion directly from the IDE. But still, I managed to work with them and they have helped me a lot.
I hope I helped.
|
|
|
|
|
Thanks screaver. That's a lot of good info.
I'm really looking for IDE integration though.
I found one called Code Co Op, which is a peer-peer source control system, so there is no server, and its about $160 (US). Which is a bit more affordable. I'm nervous about using freeware things for mission critical aspects of a business, because you can't really afford a come back on somebody that did you a favour, but cost you millions 8-)
Nursey
|
|
|
|
|
|
simple question, im sure its around here somewhere, just couldnt see it.
if someone could send a link to it, if nothing else, that would be great.
just wondering how to program my application so that it can load a file into the program once the file type is opened. say, a notepad program opening .txt files, or winamp opening .mp3s. how do you do this?
edit: i know how to open and read files etc etc, i dont need help there.. im just wondering how i can load the file automatically if it is opened with the program, or where i put the code to do this.
Thanks alot, advanced.
------------------------
Jordan.
III
|
|
|
|
|
First, you app must support command line arguments. You'll have to pick out an open command and the filename to open. Notepad is launched by a command line that looks like this:
C:\WINDOWS\system32\NOTEPAD.EXE C:\Fullpath\filename.txt
Second, check out how .TXT files are associated to Notepad. Open an Explorer window and go to Tools\Folder Options. Click on the File Types tab and scroll down to TXT. Click on it to select it, then click on Advanced. Edit the Open command and you'll see what I'm talking about as far as command lines.
RageInTheMachine9532
|
|
|
|
|
hmm.. alrighty
thanks alot. ill check it out shortly. ill try and let you know how it goes.
------------------------
Jordan.
III
|
|
|
|
|
hopefully ull b auto-emailed about this reply
iv been looking in2 it and cant seem to find any help for vb.net. i found quite a few sites for vb6 code, it looks like. ive tried it and it doesnt recognize the "Command" variable, or whatever it would be called.
Private Sub Form_Load()
If Command$ <> "" Then
MsgBox "Application started by double clicking" & vbCr & Command$
End If
End Sub
i got this from here[^]. i searched vb.net's help index, and tried the ex. given with the "Command" thing. cant seem to get it.
also, it seems most apps use the command "%1" when opening files that are associated with the app..
any more help? ...appreciated
Thanks
------------------------
Jordan.
III
|
|
|
|
|
It's not Command$ -- that's old VB6 stuff.
Look into the Environment class. You'll use either Environment.CommandLine or Environment.GetCommandLineArgs(). Docs are here[^].
The '%1' is a replacable parameter. Remember DOS batch files? When that command line is executed, the %1 is replaced with the filename (complete path) you double-clicked on. If you double-click on, say, TestFile.txt, Explorer will convert this:
C:\WINDOWS\NOTEPAD.EXE "%1"
to this and execute it:
C:\WINDOWS\NOTEPAD.EXE "C:\Wherever this file sits\TestFile.txt"
RageInTheMachine9532
|
|
|
|
|
ok sorry for the nagging, etc.. heh
Thank you lots, ill read the lib info.
Again, thx.
------------------------
Jordan.
III
|
|
|
|
|
:-DNo problem!
RageInTheMachine9532
|
|
|
|
|
ok i think iv got it.. at least up to my requirements.
by simply using folder options/file types and manually associating the file type with the app, and adding %1, or %[any number] to the parameter list, i can work with it.
i simply assign a value to System.Environment.CommandLine() and it returns the app path, and the file path which was opened with it. i was thinking way to complex. my next step is to determine how to auto. associate the file types with the app, editing the registry from the app.
Thanks.
------------------------
Jordan.
III
|
|
|
|
|
I wrote a dll in C++ that I'm now calling from a vb app. everything works fine as far as the function is concerned, but after I terminate the VB app I get a _crtisvalidheappointer assertion.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
bdiamond wrote:
I wrote a dll in C++ that I'm now calling from a vb app.
If it's broken, I probably did it
It's broken, and yes, you did it.
The first place I'd look is the C++ .dll for resources not be cleared up before the .dll is unloaded. Also, I'd double check the types I've used calling the .dll and check to make sure the call types match. It might be that there is something being pushed onto the stack in the .dll and no being popped off. Could be tht your allocating memory in the .dll and no using the MATCHED free function to free that block of memory...
...could be a large range of things... Code samples would probably help.
RageInTheMachine9532
|
|
|
|
|
well, here's the entire function. I appreciate any help you can provide me with. thanks in advance!!
int Export(BSTR szServer, BSTR szDB, BSTR szUser, BSTR szPassword, BSTR szSQL)
{
int numOfRows=0;
int numOfFields=0;
int i=0,col=0;
int connected=0;
MYSQL *dbHandle;
MYSQL_RES *res;
MYSQL_FIELD *field;
MYSQL_ROW row;
char errmsg[512];
dbHandle=mysql_init((MYSQL*)0);
CString szDBFName;
CString strPath,strTblName;
try
{
CFileDialog dlg(FALSE,".DBF",NULL,OFN_ENABLESIZING | OFN_HIDEREADONLY,".dbf files (*.dbf)|*.dbf||");
if(dlg.DoModal() == IDOK)
{
szDBFName = dlg.GetPathName();
strTblName = dlg.GetFileName();
if((szDBFName.GetLength() || strTblName.GetLength() ) == 0)
{
AfxMessageBox("Export Canceled",MB_OK | MB_ICONINFORMATION);
return 0;
}
}
else
{
AfxMessageBox("Export Canceled",MB_OK | MB_ICONINFORMATION);
return 0;
}
int nPos = szDBFName.Find(strTblName,0);
strPath = szDBFName.Left(nPos);
if(mysql_real_connect(dbHandle,
(char*)szServer,
(char*)szUser,
(char*)szPassword,
(char*)szDB,
MYSQL_PORT,
NULL,
0))
{
connected=1;
}
else
{
sprintf(errmsg, "\nError: %s\n", mysql_error(dbHandle));
AfxMessageBox(errmsg);
connected = 0;
}
if(mysql_select_db(dbHandle,(char*)szDB))
{
sprintf(errmsg, "\nError: %s\n", mysql_error(dbHandle));
AfxMessageBox(errmsg);
return 0;
}
if(mysql_query(dbHandle,(char*)szSQL))
{
sprintf(errmsg, "\nError: %s\n", mysql_error(dbHandle));
AfxMessageBox(errmsg);
return 0;
}
res=mysql_store_result(dbHandle);
CDatabase *pDB = new CDatabase;
CString strConnect;
strConnect.Format("Driver={Microsoft dBASE Driver (*.dbf)};DriverID=533;Dbq=%s;",strPath);
pDB->OpenEx(strConnect);
CString sColumns;
numOfRows = (int) mysql_num_rows(res);
numOfFields= (int) mysql_num_fields(res);
int * nFieldLen = new int[numOfFields];
int * nFieldDesc = new int[numOfFields];
for (i=0;i<numOfFields;i++)
{
field=mysql_fetch_field(res);
int nType = field->type;
int nLen = (int)field->length;
CString sCol;
nFieldDesc[i] = nType;
nFieldLen[i] = nLen;
switch(nType)
{
case FIELD_TYPE_ENUM:
case FIELD_TYPE_TINY:
case FIELD_TYPE_SHORT:
sCol.Format("%s %s,",field->name,"INTEGER ");
break;
case FIELD_TYPE_LONG:
sCol.Format("%s %s,",field->name,"LONG ");
break;
case FIELD_TYPE_FLOAT:
case FIELD_TYPE_DECIMAL:
sCol.Format("%s %s,",field->name,"FLOAT ");
break;
case FIELD_TYPE_DOUBLE:
sCol.Format("%s %s,",field->name,"DOUBLE ");
break;
case FIELD_TYPE_NULL:
sCol.Format("%s %s,",field->name,"int ");
break;
case FIELD_TYPE_LONGLONG:
case FIELD_TYPE_INT24:
sCol.Format("%s %s,",field->name,"LONG ");
break;
case FIELD_TYPE_YEAR:
case FIELD_TYPE_DATE:
case FIELD_TYPE_NEWDATE:
case FIELD_TYPE_TIME:
case FIELD_TYPE_DATETIME:
case FIELD_TYPE_TIMESTAMP:
sCol.Format("%s %s,",field->name,"DATE ");
break;
case FIELD_TYPE_SET:
sCol.Format("%s %s,",field->name,"int ");
break;
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_LONG_BLOB:
case FIELD_TYPE_BLOB:
sCol.Format("%s %s,",field->name,"MEMO ");
break;
case FIELD_TYPE_VAR_STRING:
case FIELD_TYPE_STRING:
sCol.Format("%s TEXT(%d),",field->name,nLen);
break;
}
sColumns += sCol;
}
sColumns = sColumns.Left(sColumns.GetLength() - 1);
sColumns = "CREATE TABLE " + strTblName + " (" + sColumns + ")";
pDB->ExecuteSQL(sColumns);
CDBFRecordset* m_Set = 0;
m_Set = new CDBFRecordset;
m_Set->Open(szDBFName);
for(i=0;i<numOfRows;i++)
{
int MaxLen = 0;
CString sYear,sMonth,sDay,sTime,sHour,sMinute,sSecond;
row=mysql_fetch_row( res );
m_Set->AddNew();
for (col=0;col<numOfFields;col++)
{
BOOL bDate = FALSE;
BOOL bMemo = FALSE;
field=mysql_fetch_field(res);
int nType = nFieldDesc[col];
MaxLen = 512;
switch(nType)
{
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_LONG_BLOB:
case FIELD_TYPE_BLOB:
bMemo = TRUE;
MaxLen = 10000;
break;
}
char * msg = new char[MaxLen];
sprintf(msg,"%s",row[col]);
CString str = msg;
COleDateTime * t;
switch(nType)
{
case FIELD_TYPE_YEAR:
case FIELD_TYPE_DATE:
case FIELD_TYPE_NEWDATE:
case FIELD_TYPE_TIME:
case FIELD_TYPE_DATETIME:
case FIELD_TYPE_TIMESTAMP:
str.Remove('-');
int len = str.GetLength();
sYear = str.Mid(0,4);
sMonth = str.Mid(4,2);
sDay = str.Mid(6,2);
if(len > 8)
{
sHour = str.Mid(8,2);
sMinute = str.Mid(10,2);
sSecond = str.Mid(12,2);
}
else
{
sHour = sMinute = sSecond = "0";
}
bDate = TRUE;
t = new COleDateTime(atoi(sYear),
atoi(sMonth),atoi(sDay),atoi(sHour),atoi(sMinute),atoi(sSecond));
break;
}
COleVariant fVar;
if(bDate)
fVar = *t;
else
fVar = str;
delete [] msg;
m_Set->SetFieldValue(col,fVar);
}
m_Set->Update();
}
AfxMessageBox("before deletions");
mysql_free_result( res ) ;
m_Set->Close();
if(m_Set)
delete m_Set;
if(pDB)
delete pDB;
AfxMessageBox("after deletions");
return 1;
}
catch(CDBException* e)
{
e->ReportError();
e->Delete();
}
catch(CException* e)
{
e->ReportError();
e->Delete();
}
catch(...)
{
AfxMessageBox("Unhandled Error.",MB_OK | MB_ICONINFORMATION);
}
return 0;
}
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Well, I've never used MySQL before, but since it pretty much follows MSSQL this shouldn't be a problem.
Something I've noticed with pDB is never told to Close. I'm assuming there is one considering there is an OpenEx(). And mysql_real_connect returned a dbhandle. I'm assuming there must be a function to close that handle and release the resources that it represents.
RageInTheMachine9532
|
|
|
|
|
I edited my code to include a dbHandle->free_me and a pDB->Close(), but I still get the same thing.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Are you using a Release compiled .DLL and a Debug compiled .EXE? Try compiling the thing entirely Debug or entirely Release and see what happens.
RageInTheMachine9532
|
|
|
|
|
the dll is a release compile, and .exe is made in VB
If it's broken, I probably did it
bdiamond
|
|
|
|
|
I've been doing a bunch of reading on the mySQL package. What version are you using? There seems to be a bug in some fairly recent releases that can cause this problem. I've also run into examples where when you first create the mySQL object, a default connection is created. You might want to try dropping/closing this connection first before your try to create a new one with your existing code.
RageInTheMachine9532
|
|
|
|
|
Hi
Hopefully someone can help me with this problem.
I have a 3 page workbook (report,data1,data2).
data1 and data2 are loaded as External Data from 2 csv files and are updated at 10 minute intervals. Both sheets have the same layout -:
Col A = date (i.e. 12-DEC-04) (as string)
Col B = reference (i.e. ABC1234) (as string)
Col C = value1 (as integer)
Col D = value2 (as integer)
Col E = value3 (as integer)
The report page has 3 columns.
Col A = date (as Date)
Col B = reference (as string)
Cols C - F = various values
Col G = valtotal (as integer)
I've written a function that takes in 4 parameters (ref,date,page,reqcol).
"page" sets which of the sheets is used for the info (data1 or data2).
"Reqcol" sets which column from the data sheet is reqd.
(e.g. Cell G4 on the report might be =vallookup(G1,A1,"data2","E"))
This has to loop over the data checking all references, and if it finds a match then check the date. If both match, it returns the value in column (reqcol).
The data size is not known until the data is refreshed (cell A1 contains the number of rows).
A variable, 'lastrow', is used as the number of rows and a number of loops is performed.
The function appears to work sometimes, but other times won't work - on the same data!
Also, I need to have an easy way to refresh the values returned by the funcion on the report page without having to hit 'Enter' on each cell.
Here is the function as it stands......
Public Function vallookup(ref As String, dateref As Date, page As String, reqcol As String)<br />
'Activate correct page sheet<br />
Worksheets(page).Activate<br />
'Get size of dataset<br />
lastrow = Worksheets(page).Cells(2, "A").Value<br />
'Loop data<br />
For a = 1 To lastrow<br />
If (UCase(ref) = UCase(Worksheets(page).Cells(a, "B").Value)) Then<br />
If (dateref = DateValue(Worksheets(page).Cells(a, "A").Value)) Then<br />
vallookup = Worksheets(page).Cells(a, reqcol).Value<br />
End If<br />
End If<br />
Next a<br />
End Function<br />
<br />
<br />
Sub Refresh()<br />
'Attempt at a Refresh function<br />
Worksheets("report").Calculate<br />
End Sub
|
|
|
|
|
I just started using WebMatrix and ASP.NET, and I have one problem - I like to know, how I can do it:
Situation - I have one page "Licence agreement" with Agree and Disagree; when user click Agree, then must open Registration form (I made it in that way: Response.Redirect("Reg.aspx")). So far is OK! But I need, that the form Reg.aspx opens only when in Licence form users click Agree - shortly - it (Reg) should no opens, when users write in adress bar http://www.xxxxx.com/Reg.aspx...
Sorry for my english, but I hope that U understood my problem. I use VB.NET
|
|
|
|
|