Beautiful! I use Oracle also. (I also had better luck using Oracle's provider, instead of the Microsoft OLE DB for Oracle provider.) I've actually used that method (pull a default row)- I take the default "take everything" accessor, and change it into a "get me the row with this primary key" parameterized query. If the accessor returns a row, I know that the data already existed in the table. If the rowset is empty, then I set the values up and update the row. Of course, you can handle this by checking out HRESULT and etc to determine if the row already exists... You probably want to create a command object instead of a rowset object. That way you can do direct insert/update/deletes, as well as run stored procedures. In fact, you might want to turn your insert into a stored procedure! Either way, at the top of the accessor, add in all your member variables (TCHARs, DOUBLEs, etc) just as if you were dealing with a rowset accessor. In fact, you might already have this if you created a default rowset accessor! Then, define your parameter map... BEGIN_PARAM_MAP(CNAMEOFACCESSORAccessor) COLUMN_ENTRY(1, mFIRSTFIELD) COLUMN_ENTRY(2, mSECONDFIELD) COLUMN_ENTRY(ETC...) END_PARAM_MAP()
Make sure you defined mFIRSTFIELD and mSECONDFIELD and etc first. Now, change up the default "rowset" command that you were given. DEFINE_COMMAND(CNAMEOFACCESSORAccessor, _T("INSERT INTO MYTABLE VALUES (?, ?)"))
Look down at the in the command class that ATL built for the OpenRowset method. Look for return CCommand<CAccessor<CNAMEOFACCESSORAccessor>>::Open(mSession);
You've gotta change the CCommand::Open parameters. (Look it up in the MSDN, search for "CCommand::Open".) Leave the first parameter as m_session. You can set the second parameter, szCommand, to NULL because you're using the Accessor for the command. The third parameter would be for a property set, if you defined any. (If you're calling an insert, I'd think you would... I used stored procedures so I can't say for sure, but I think you'd need DBPROP_UPDATABILITY.) The fourth parameter's important, that's a pointer (pRowsAffected) to the number of rows that got DML performed. In your case, this should come back as 1 for a successful insert. (Negative 1 means no rows affected, as does a NULL pointer.) Hope this helps; or at least gives you something to search the VC++ help files and the web for! Oh- for the code where I queried first for the data, and if I got no rows bac
ThomasH1
Posts
-
Beginner OLE question -
Visual Studi .NET (2003) is weirdIt sounds like a language pack issue; you might want to search support.microsoft.com for something like "language Visual Studio .NET". -Thomas
-
Beginner OLE questionI take it you're using Visual C++, and native OLE DB with ATL? I've inserted rows into large tables before without any problem. You're using a "real" database, right? (I don't consider Microsoft Access or FoxPro as a real database.) I'm confused by this statement: errenden wrote: The question, is there any way to use the accessor to do the insert without populating it? What is it that you don't want to populate? Are you talking about the "generic" query that the accessor uses by default, where it selects every row in the table? And you're concerned about the program selecting every row first, and then adding your new row to the end? -Thomas
-
Opinions on loading large file into database?Hello everyone, I'd like your opinions! I'm rewriting a program that I did back in 1996; it takes a large "external-system" text file, and compares it against our database. If there's a difference between the file entry and database entry, we'll take the entry in the file and put it into the DB, and make note of it on a report. We don't run this program often, and we always take the file as the "correct" data. I'd like to load the file into an ADO.NET dataset, but I'm a little hesitant because of the average file size. The size of the flat file is usually between 2 and 4 MB large. Is this an okay size for a dataset in memory? I'd want to load up the entire file at one time into a dataset. Then I'd set up a DataAdapter and DataSet and etc for my database, and compare both datasets together. I could just call DataAdapter.Update on the database's dataset to make the changes. So not only would I have the 2-4 MB flatfile in memory, but I'd also potentially have the same size (2-4MB) from the database! The benefit is that I'd really be "using" ADO.NET... comparisions would be easier, and the update would be cleaner. My alternative is to open the file, and read it one record at a time. I'd then do an executescalar to check our database, and another executescalar if I had to update our database. This method seems memory-friendly, but database-intensive and network-intensive because of all the individual transactional updates... I'd have to update the database one-record-at-a-time! Do any of you load up huge 2-4 MB text files into a dataset? If so, do you have any problems with this approach? I really want to use datasets- but this program will be running on workstations, on an as-required basis- it won't be running on a server, so I don't want to write a program that takes forever to run. The workstations are semi-powerful; but this "might" have to run on an XP Pro box with only 256MB of memory. (Most of the XP Pros have 512 mb ram.) Oh, I'll be using C#.NET and ADO.NET under .NET Framework version 1.1. The file isn't in XML, and I think it would be pointless to convert it to XML first, and then process it. Correct me if I'm wrong, though! Thanks for any ideas! -Thomas
-
"Bad Form" to use public class variables without get & set?Steven & Judah, thanks! I guess I'll change those fields into properties- I hate "breaking style". The class is sealed- it's basically for some help during a system data migration- but as trivial as it is, I don't want any poor coding habits popping up! -Thomas
-
"Bad Form" to use public class variables without get & set?Hey everyone, just wondering what your thoughts are on Get & Set! I've got a class in which I have two public variables. The class itself changes their values, and any calling class can also change the values. Is it "bad form" to just leave these variables public? Or should I turn these into class properties by doing:
private int _myvar; public int myvar { get { return _myvar; } set { _myvar = value; } }
The class is so specialized that I don't need to do any checking during a "set" when I call the class methods. My instinct says that I'd get a microsecond or two of a performance boost by just leaving myvar as public, and eliminating the private/get/set/propery code. But I'm curious as if to this is bad form. I could see if I had to prevent a "set" operation, or perform a check on the value first- but I don't have to do either of these. Thanks! -Thomas -
Missing System.Data.OracleClient namespace- what am I missing?Yep, that was the problem. Just had to right-click "references" in the project window, and say "Add"! -Thomas
-
Can't get value from DataSet into variable without explicit casting?Hey guys, got a question for you all! I've got a DataSet/DataTable, created by using a DataAdapter.Fill call. I'm writing a C# class that handles all the ADO.NET work I need, and a different class will call the public methods of this class. So; I've created the two public properties I need-
Public String _custId
andPublic DateTime _orderDate
. But, I can't get the values out of the DataSet/DataTable/DataColumn without doing (in my mind) useless casting! For instance, this doesn't work:_custID = dsOrders.Tables["tblOrd"].Rows[iCurrentRow][0];
I get the message "Cannot implicitly convert type 'object' to 'string' ". To make it work, I have to do:_custID = (String)dsOrders.Tables["tblOrd"].Rows[iCurrentRow][0];
....or...._custID = dsOrders.Tables["tblOrd"].Rows[iCurrentRow][0].ToString();
I'm confused as to why? The following line displays "System.String":Console.WriteLine(dsOrders.Tables["tblOrd"].Rows[iCurrentRow].Table.Columns[0].DataType);
So, shouldn't that mean that I don't have to do anything else? Why do I need to use (String) or .ToString() ? And I also can't get the DateTime into a variable. Trying_orderDate = dsHousing.Tables["tblOrd"].Rows[iCurrentRow][1];
gives me "Cannot implicitly convert type 'object' to 'System.DateTime' ". And, again, if I display the value for Columns[1].DataType, it shows me "System.DateTime". Worse, there's no ".ToDateTime()" method of the Column object, so the only way I can get the DateTime field out is to cast it to a string, and then convert it back to a DateTime. Compared to my problem with the String column, I'm doing twice the un-necessary work just to get the DateTime column! Is this really what's supposed to happen? If the DataType shows string, why do I need to perform an explicit conversion from object to string? It seems like I'm doing un-necessary work; if the value is stored as a certain datatype, I should be able to pull it out of the DataTable and put it into a variable of the same type. I even toyed with the idea of .NET assuming I wanted the DataColumn being put into a String- but I can't find a property of DataColumn that just gives me the value. In classic ADO, there was a Field object, which had a Value property. I can understand "DataColumn" being an object, but is there a specific property for pulling the value out of DataColumn? For instance, if those code samples I just gave would be in classic -
convert access database to mysqlThe only technical thing I know about Access is that it never should have been written. Even MSDE is better than Access! To be safe, I'd export the Access database as a CSV file, manually create your schema inside MySql, and then tell MySql to import the CSV file. It's a little more work then a fancy point & click tool, but you know your data will go through perfectly. -Thomas
-
Missing System.Data.OracleClient namespace- what am I missing?Hey guys, what am I missing here? System.Data.OracleClient gets installed with .NET Framework 1.1, correct? If I set up a "using System.Data.OracleClient;" in my C# code, I get an error message that says "The type or namespace name 'OracleClient' does not exist in the class or namespace 'System.Data' (are you missing an assembly reference?)". I looked in C:\windows\Microsoft.NET\Framework\v1.1.4322, and yes, there is a System.Data.OracleClient.dll file. So I think I'm missing something easy... anybody come across this yet? Oh the PC is Windows XP Pro, and I'm using Visual Studio 2003 Enterprise Architect, with .NET framework 1.1 - the 1.0 framework has never been installed on this PC (the computer is one month new). If, inside of the VS.NET IDE, I start typing "using System.Data.", Intellisense only shows me choices of "Common, Odbc, OleDb, SqlClient, SqlTypes". OracleClient isn't on the Intellisense list, but even if I force-type it, I still get that build error. Thanks! -Thomas
-
weird Oracle problemI take it that you installed the Oracle Server on the same PC that you program on? If you connect from another computer (you'll have to install the Oracle Client), it should prompt you for a password. Remove the "NTS" from the SQLNET.AUTHENTICATION_SERVICES list in your sqlnet.ora file. If that's the only entry, you can put a pound sign (#) in front of the line. That will disable the integrated NT authentication, and require you to use a password. Don't forget to also change your SYSTEM user's password; the default password for SYSTEM is "manager". Incidentally, it'd make a world of difference for speed if you kept the Oracle server on a different computer then the one you develop with. You could even push Oracle onto an older, slower computer- as long as you meet the minimum system requirements for the Oracle Server, you'll be OK. -Thomas
-
Thoughts on response.redirect? Anyone have 0 problems? Or, anyone have problems?So nobody has any idea... or opinions, or even Guesses? Nobody uses response.redirect here? I thought for sure that someone would. Or did I make my question too technical? If I did, let me know, and I'll rephrase it. Thanks! -Thomas
-
No expert of ASP.Net on codeproject????I've often wondered the same thing (as far as experts go), seems all my questions go unanswered- probably because they're too difficult! Anyway, did you try doing a Debug/Start without Debugging? Have you looked at the IIS logs? Have you looked at the Win2k Event Logs (start/settings/control panel/administrative tools/event viewer)? Have you tried debugging while logging on as an administrator? Are you running URLScan? If so, have you checked those logs? -Thomas
-
Thoughts on response.redirect? Anyone have 0 problems? Or, anyone have problems?Hey all, got one of those "real world" questions for everyone! I've got a classic ASP application that uses multiple .asp pages, each with a form. The user fills out 5 pages of forms, each one linking to another, using the old <form action=post action="nextform.asp"> setup. Example- user fills out their login information, and clicks next. Then, user fills out their preferred shipping information, and clicks next. Etc, etc. Now with .NET and code-behind, I have two options for moving the user to the next page. One is response.redirect, the other is server.transfer. They'll click the submit button, which will do a postback to the original form. Then, my code-behind saves the info into the session object, and will either redirect or transfer the client to the next form page. I target a "global" audience with my application, so I'm a bit concerned about the compatability of all this, as follows: Response.redirect: The W3C (World wide web consortium), for the HTTP protocal version 1.1, leads me to think that I (and therefore, all of us) are abusing the redirect command (302). It seems that the 302/redirect command is only for sending a user to a URL that's moved. It also seems to say that some browsers will misinterpret this as a GET, instead of a POST command. See the document here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.3 Besides the temporary relocation part, I'm concerned where it says that "the user agent (browser) must not automatically redirect the request unless confirmed by the user". Server.Transfer: This seemed like the answer, but it might not return valid HTML (multiple <body> tags)- and that might fail against my "global" target audience. That just about throws server.transfer out of the window for me; and leaves me with only one solution- response.redirect! Another solution is to possibly make one large page, with all the forms on it, and only making one visible at a time. But I see this as a particularly messy bit of code that would quickly become more trouble than it's worth. I analyzed the IIS logs of my application, and found out that 95% of my users were using at least IE 5.0. So this might "help" me, in that I can assume that response.redirect's will function as expected. So what I'd really appreciate from you guys is your thoughts on this! Have you deployed apps that work perfectly, using response.redirects? Or have you had probl
-
FrontPage Server Extensions- 2000 or 2002?OK, that's it, I've had enough. Roger (& all who might be reading), I can't even debug the application with FPSE!! Get this; I can create the page fine, no problems; it asks me for a login to the test domain, and creates the page. When I try to run/debug the project, it logs me out of the test domain, and tries to re-login with my MAIN domain credentials!! And of course those fail! So it throws up an error message and tries to be helpful by saying "make sure you're a member of the debuggers group." My test domain account is, but of course my main domain account isn't (and I'm not about to create a forest to join the two domains)! So, I've had it. I'm going to load and run IIS locally, run the Microsoft IIS lockdown tool on it, and be done with it. I'm also going to swipe your idea, Roger, if you don't mind- making the web site into a "virtual directory" pointing to a share on the test server/domain. And then I'm going to redirect my default location for my local project info (my docs\visual studio projects) onto the Main domain. This way I'll be able to work from home. So my test server will be what it was when I was running VS6.0, just a server/domain used for compatability testing and load testing and etc... no development integration. Won't be able to use Visual SourceSafe then, but I'll just resign myself to manual backups again. Maybe I'll attack all this again when Whidbey comes out. :D Thanks again for your help RW!! -Thomas
-
FrontPage Server Extensions- 2000 or 2002?I double checked, and yep, I had added myself to all those groups. Looks like I'm SOL... I think my problem is that I'm trying to be a member of two domains. I think if I could see both active directory trees- or even just the tree for the test server, then my PC would be able to "find" the webserver (on the test domain). I'm betting the only solution is to somehow create a forest between the two domains, but I really don't want to tie our production server into my test server. At least I figured out the error I was getting from FrontPage... it was telling me that "Unable to retrieve folder information from the server. Access forbidden." I finally traced it to something stupid... for the "Directory Security" tab of the "default web site" properties, I restricted the access to deny all but my subnet, and two other off-site ip addresses. Well, when a new project was made with Frontpage extensions, the new folder was taking ONLY the static IP's, not the subnet allowance. So I solved that one with a workaround; I just added my own static IP to the default web site's directory access, which actually wound up making my code a bit more secure. If I want anyone in my company to "use" my site, then I could give 'em access by their IP. So each new directory that Frontpage extensions creates has those three IP's, but it still neglects the subnet IP's- which doesn't bother me. :) Tomorrow I might bring my laptop in, make it a member of the test domain (it's not a member of Any domain right now), and see if the file share option works 100%. I'll keep you (and codeproject.com) posted! Thanks! Man, ya know, the setup of this environment was NOT supposed to be a pain; I figured the hard part would've been the coding and debugging. (laughs) -Thomas
-
FrontPage Server Extensions- 2000 or 2002?I'm trying to follow the semi-isolated model of development, as written up in Microsoft's "Patterns & Practices" series. Find that document here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/tdlg_ch2.asp. Find another similar writeup here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vetchWebProjectsSourceControlIntegrationInVisualStudioNET.asp. So according to that KB 320451, IIS needs to be installed in order to get the ADSI component installed, and the IIS5 docs say that the IIS Admin Object exposes ADSI methods to configure the remote web server. But I don't want IIS running... so I was hoping that I could install IIS locally, keep it off, but get the ADSI functionality that would "find" my remote webserver. Well, I gave it a shot, and I was wrong- on ALL counts. I installed IIS, kept all services and the default web page running, but still got the error messages from KB 320451. For kicks I tried my idea of shutting all of IIS down and trying to create a web project, of course, the same error messages came up. So apparently my computer doesn't like ADSI at all, and I can't use the file share option for creating a web project. But... now I'm wondering if it's because of my domain layout. I work in two domains- production and test. Each domain has it's own DNS server, the two domains are completely isolated from each other. My workstation PC (Win2kPro) is a member of the production domain. I can access the test domain thru exploring "my network places", or doing a start/run/\\servername. And then I'm back thinking to Active Directory Service Interfaces. The only Active Directory that I can see by exploring "My network places" is the ad for the production domain. I can't see any ad for the test doman. So that makes me wonder if my file share method is failing because VS.NET is search the Production domain for my remote web server, when in fact, it should be searching the Test domain! Ugh. I'm a 1/2 step away from calling Microsoft on this one. This wasn't a big deal with Visual Studio 6.0, but then again, when I developed my ASP apps, I used Interdev 6.0 to just create standalone files on a share from the test domain- I nev
-
FrontPage Server Extensions- 2000 or 2002?Roger, thanks for the info!! I'll forget about FPSE 2002! Do you use FrontPage to create your web projects? Just wondering if you know anything about my question regarding IIS (installing it locally but keeping the services and web page stopped, just to get the Active Directory Service Interfaces component installed.). Thanks! -Thomas
-
FrontPage Server Extensions- 2000 or 2002?Hey guys, what's up? Just set up my remote server (using semi-isolated development mode) for web projects (namely C# ASP.NET projects), and found the info about updating to FPSE 2002. I didn't think I -needed- FPSE, except that I don't want to run IIS on my development PC (Win2kPro). So I'm using my test server (Win2kServer) as a remote web server. Wound up with a ton of error messages (well, actually, only two), and found the answer in Microsoft KB # 320451. So apparently I need FPSE, because I really don't want IIS locally. Anyway- should I upgrade the test server to FPSE 2002? Anyone done this? Any problems with it? Or... like I said, I really don't want IIS running locally. But- I much rather like the idea of talking to my test server via a file share (wwwroot$). Would the ability to use a file share work if I installed IIS locally- but stopped the "World Wide Web Publishing Service" and the "IIS Admin Service"? That way, IIS gets installed on my client computer, but I'm wondering if ADSI (Active Directory Service Interfaces) would still work. The KB says it's integrated with IIS, but I'm not sure how. Did anybody try this? Or, /could/ anybody try this for me? I just tried to create a C# ASP.NET web application, and wound up with both of the error messages that KB #320451 talks about. Oh, let me link up KB 320451 - click here for the article! Thanks!! -Thomas
-
Don't want to install IIS locally- how are your development environments set up?Hey all, I'm just getting into VS.NET and ASP.NET and etc. I previously used classic ASP and a text editor (I have InterDev 6.0 but never used it), so I'm just wondering how you've set up your VS.NET development environments. The VS.NET IDE makes much more sense to me then that InterDev junk, but I'm not sure how to set up my computer with it, because: I don't want to install IIS locally on my machine! My development environment with Visual Studio 6.0 and ASP stuff was: 1. Development PC, Win2000 Pro, VS 6.0 2. Test server, Win2k advanced server, IIS 5.0 3. Production server, Win2k advanced server, IIS 5.0 ** ALL machines are "mirrors" of patches/MDAC versions/updates/software versions/etc Right now I've got VS.NET on my XP-Pro laptop with IIS 5.1 running. It's on my notebook because I don't want to change my development PC. For example, all three computers above have Win2k SP 3 with MDAC 2.5 (not SP4 with MDAC 2.7). I'm "learning" the VS.NET suite, so this one-computer environment works for me- for now. But here's where I get concerned about the setup of test servers and production servers and not running IIS locally: When I create a new C# "ASP.NET Web Application", I tell VS to put it on http://localhost/myapp . That's all great for now since I'm using my laptop, and, of course, have full rights/access to the hard drive. (When I use VS.NET, I log in as administrator to XP-Pro, and pull the ethernet cable out.) How would I create a "ASP.NET Web Application" in the above 3-system development environment? Would I tell it to use http://mytestserver/myapp ? Or would i have to use the FQDN, such as http://mytestserver.mycompany.org/myapp ? Would I just need to share the D:\inetpub\wwwroot folder out in my test server's AD? Or do I have to put read/write/everything privleges on the virtual directory inside the test server's IIS snap-in? Do I need to add additional shares to the test server... such as, does VS.NET try to put anything in the C:\WINNT directory? I'll need to install "Frontpage extensions" on the test server, right? Also, how in the world would I move changes to my production server? Would I just copy over the files that have changed? Or do I need to copy the whole directory to the production server? Is there some kind of deployment wizard that would take care of this? Do I need FrontPage Extensions on my production server?? I'd rather not install those; I prefer to keep extra crud off the production systems. I used to just develop ASP.NET pages in TextPad