Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. First, do you want to return the last 4 digits of SSN, or use the last 4 as part of the WHERE clause to filter by? Here's how you select the last 4 characters: SELECT Right(SSN, 4) AS [shortSSN], DateOfBirth FROM Validation WHERE... Now I assume you have two textboxes, txtSSN and txtDOB that you want to filter by. If the SSN textbox contains the full SSN, then - in other words you want to filter on an exact match - then do this: Sql1 = "SELECT SSN, DateOfBirth FROM Validation WHERE SSN = '" + txtSSN.Text.Replace("'", "''") + "' " Sql1 = Sql1 + " AND DatOfBirth = '" + txtDOB.Text.Replace("'", "''") + "'" If the txtSSN might contain the first few characters of the SSN (most common), use LIKE. The big difference below is the word "LIKE" and the use of "%": Sql1 = "SELECT SSN, DateOfBirth FROM Validation WHERE SSN LIKE '" + txtSSN.Text.Replace("'", "''") + "%' " Sql1 = Sql1 + " AND DatOfBirth = '" + txtDOB.Text.Replace("'", "''") + "'" If the txtSSN might contain the last few (or 4) characters of SSN, be prepared for a SLOW search as all databases will have to do a table scan to find matching rows: Sql1 = "SELECT SSN, DateOfBirth FROM Validation WHERE SSN LIKE '%" + txtSSN.Text.Replace("'", "''") + "' " Sql1 = Sql1 + " AND DatOfBirth = '" + txtDOB.Text.Replace("'", "''") + "'" In the above, the "%" went on the front of the string - that's the only difference. For the record, always use Replace("'", "''") when passing strings to a database SQL statement. Badly formed strings (with single quotes) could cause errors, or worse with malicious users. -Ner
  2. I would use a DataView, as in: Dim ds As New DataSet ds = dataAccess.ExecuteDataset(conn.ConnectionString, CommandType.StoredProcedure, "GetAllTranscripts") ' I don't remember the enum for the last param, might not be ' DataViewRowState... check the definition of the DataView constructor Dim dv As DataView = New DataView(ds.Tables(0), "TranscriptsID = 681", Nothing, DataViewRowState.CurrentRows) DataGrid1.DataSource = dv DataGrid1.DataBind() You can create as many DataViews as you want from one Table. Each can have its own filter and sort. In the above, I passed Nothing for the sort - but you can pass a comma delimited list along with "asc" or "desc" for each column. -Nerseus
  3. I'm not sure if the following will help, but maybe check out this link for a Card Game type of demo: http://www.xtremedotnettalk.com/showthread.php?s=&threadid=49509 -Ner
  4. Do you want to find a row/cell by some data value and highlight that cell? In other words, find a row where Col1 = 'some value' and then locate column x and highlight it? You can use the Find method of a DataView to get a row by index. If you just need a reference to the Row and Column (and not in particular where that value is in the grid), you can use the DataTable's Select method which returns a DataRow array. -Ner
  5. You don't really need them in the same namespace. Here's what you can do though. Assuming you have Solution named Project1 with a project WinExe1. Also assume you have another solution with a project WinExe2. Now suppose you want the forms from WinExe2 to be available in WinExe1: 1. Open your solution for WinExe1 and right click the solution and select Add Existing project. Select your WinExe2 project. 2. Right click your WinExe2 project and click properties. Change the project type from Windows Executable to Class Library. 3. Expand the references node for WinExe1 and click Add Reference. Select the Projects tab and select the WinExe2 project. Now in your WinExe1 project, add something like: Imports WinExe2 to the top of one of your classes. Import whatever namespace you used in the second project. Now that class in WinExe1 should be able to create an object from WinExe2, including forms. The two keys are keeping the projects in one solution and making sure the second project is a Class Library. You can always switch it back to a Windows Exe for testing separately later - I do that all the time. -Ner
  6. Break down the previous into two simpler questions: 1. Suppose I wrote a managed C++ DLL that contained a class that was inherited from a class defined in an .h file. How would I go about passing that class (from C++) to a C# DLL? 2. Or, how would I expose the C++ class to the C# DLL? If it's a managed C++ DLL, is it much like a C# DLL in that I can just add a reference in the C# project and get access to the class? Would it matter if the C++ DLL (written in VC++ .NET - whatever version it is, 7?) were unmanaged? Could I still add that DLL reference to a C# project, or would it have to be called using DllImport. If I have to use DLLImport, would I have to define the class in C# in order for the DllImport definition to match the class being passed in from the C++ DLL? Egads I'm tired and working too much, too late. If you can help, thanks. If not, join the crowd around my desk in the morning for Krispee Kremes :) -Nerseus
  7. Howdy! I'm trying to write a DLL that will interface into an existing library (more or less a plugin). The executable loads a DLL file (say "test.dll") and expects that DLL to implement a specific class. The class definition is in a C++ header file (.h) that I have. I can easily create a test project in C++ that implements the given class and it works. Meaning, my standard C++ DLL compiles and the external executable loads it and instantiates the class and calls the method I need, doing what I want (yee haw!). Now there are a LOT more classes and a lot more code to do and I'd really prefer to NOT do it all in C++ as I'm not that proficient. And I hate doing it all in VS6 (I can't use C++ .NET as the class I need to implement contains some functions with optional parameters and other issues that .NET doesn't like right now). My idea is to create a simple C++ DLL in VC++ 6 (or maybe C++ .NET) that can then instantiate a C# DLL and passthrough all method calls. Since I have the LIB file (and mabye even the source that created the LIB file), I was hoping there's a way to extract out the definition of the classes and get them in C# syntax. Asking too much? I've only just begun! But that's all for now :) This is all to use an existing library from a 3rd party that no longer supports the product. We know the code works because we've used it, but we'd really like to port as much as possible to C# without taking the hit of converting the WHOLE C++ project to C#. -nerseus
  8. Yes, all Trinitron (Sony) monitors have the two lines. They're definitely there and it depends on who's viewing as to whether or not they're visible. About 5 years ago when I got my first Trinitron I called Dell tech support and they were clueless (at the time) and suggested I try changing my background colors to light gray to minimize the line's appearance (!). I then used Trinitrons for the next 4.5 years and eventually got used to it. So much to the point that I don't think over the last few years I thought much about it though that first year it annoyed me to no end. I have friends, however, that say they can't even see the line unless someone points it out. I think they're blind. Suffice it to say, it's there on new and used monitors and by itself is nothing to worry about. Now screen burn-in on the other hand... watch out. :) -ner
  9. Here's one article. I know that Chris Sells authored at least two related to security for downloadable apps. My company used the idea, but implemented it from scratch. Our idea was to download DLLs that contained forms but do it from a regular EXE, client side. The article you mentioned does mean modifying each user's security settings to allow the app more permissions or working within the permissions you have. For most robust data-driven apps, the security provided won't be enough. A custom downloader can take awhile to implement of course, since it's custom code, but can be highly dynamic. Ours, for instance, uses a loader that downloads the main EXE and can even update itself (the loader updates itself). The main EXE can then authenticate a user and analyze their permissions and download DLLs accordingly. -Nerseus
  10. Yes, but I need a maximum size as well. Say the text is normally "Hello World", so I make the label 100 pixels width. There are too many other controls in the same area to make it any bigger and it works 90% of the time. But one time the text is "The quick brown fox jumped over the lazy dog biscuit" and now my label wraps, looking pretty ugly. I could "cheat" and make the height *just* tall enough to only show one line, but it's a pain to get things aligned right. If I use a textbox, the extra text is there, but you have to scroll to see it. That works, but it's not ideal. I think maybe I'll just go with the inherited label, but I wish there was a way to simplify the alignment logic. And I'm still confused as to why the border draws when I'm not doing it, and I'm supposed to be the only one drawing the control (that's my impression anyway). -Nerseus
  11. I have a few places where I need to display text that will normally be an inch or so wide (relative of course). For some rows the text is extra long (maybe 3 or 4 inches). It's a common problem and so far I've used the common answer: use a textbox that looks like a label (no border, readonly, cursor=Default, TabStop=False). But it's kinda hokey and takes up a lot more resources to draw a textbox when I just need a read-only label. Is there, in fact, a way to get a label to have No Wrap enabled like a non-MultiLine Textbox? I've got a few inherited label controls that do custom drawing. I know I could write a NoWrapLabel control, but it seems like a lot of work when a property might work. If I *did* write the inherited label, I believe I'd have to have the following code (I don't know of any way to simplify this into a few short calls): (Also - why or HOW does the BorderStyle property still work - I have NO code below to draw it, and I'm not calling base.OnPaint) public class NoWrapLabel : Label { protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics g = e.Graphics; StringFormat sf = StringFormat.GenericTypographic; sf.FormatFlags |= StringFormatFlags.NoWrap; // Set the horizontal alignment switch(this.TextAlign) { case ContentAlignment.BottomCenter: case ContentAlignment.TopCenter: case ContentAlignment.MiddleCenter: sf.Alignment = StringAlignment.Center; break; case ContentAlignment.BottomLeft: case ContentAlignment.TopLeft: case ContentAlignment.MiddleLeft: sf.Alignment = StringAlignment.Near; break; case ContentAlignment.BottomRight: case ContentAlignment.TopRight: case ContentAlignment.MiddleRight: sf.Alignment = StringAlignment.Far; break; } // Set the vertical alignment switch(this.TextAlign) { case ContentAlignment.BottomCenter: case ContentAlignment.BottomLeft: case ContentAlignment.BottomRight: sf.LineAlignment = StringAlignment.Far; break; case ContentAlignment.MiddleCenter: case ContentAlignment.MiddleLeft: case ContentAlignment.MiddleRight: sf.LineAlignment = StringAlignment.Center; break; case ContentAlignment.TopCenter: case ContentAlignment.TopLeft: case ContentAlignment.TopRight: sf.LineAlignment = StringAlignment.Near; break; } // Clear the area of the control e.Graphics.DrawRectangle(new Pen(this.BackColor), this.ClientRectangle); // Draw the text e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), this.ClientRectangle, sf); } } Thanks, Nerseus
  12. That's what I thought... couldn't find anything to back it up though. I'll investigate whether I can code a simple C++ DLL that wraps calls to a C# assembly. Yuckums, working with older code :) -Ner
  13. I can't remember this offhand and a search on google didn't get what I expected (too vague I guess). Can C# (or managed .NET) compile a "standard" DLL? Meaning, such that the DLL can be used from in, say VB6, or that you'd define through DllImport (such as BitBlt or timeGetTime or other Win32 DLL functions)? I'm not concerned about difficulty, just wanting to know if it's possible (maybe some kind of attribute decorations or somesuch)? Thanks a bunch :) -Nerseus
  14. I can't really picture what you're doing - I mean, I can, but I can't imagine why you'd want this. You have 3 (or more) controls on top of each other? If all 3+ are the exact same size, I'd think you'd only want one visible at a time (easy enough to fix). If you really have 3+ controls the same place, but different sizes... well it seems like it would be confusing (overlapping controls that pop in front/behind other controls)... maybe I'm missing it. Unfortunately, I know of no built-in .net way to do what you want (SendBackOneZ or something similar). It may be similar the "insert a new tab at position x" problem. Meaning, you can't do it directly but have to reorder all the controls calling SendToFront for each of them, in order. You might also look at the Win API to see if that is something that's built in. You might be able to make the call that way and save some time. -Ner
  15. I'd put it under "Experience" or something similar. Beta testing is good, but being a customer service representative is a bit different. It sounds like they'll be wanting you to watch over things, not unlike the police maybe?, and report on people's play. I would assume that also means helping out newbs, reporting supposed bugs, suspected cheaters, etc., and possibly give out warning to "mean" people and such. Could be fun - but I noticed it's not part time. Are you leaving school for this? -Ner
  16. Binding a DataGrid to a DataSet is one way to view the data, sure. You can also use test.GetXml() to return a string of the XML version of the data. You could write it to a file with test.WriteXml(...) or just use something like "Debug.WriteLine(test.GetXml())" to view the XML in the Output window. -Ner
  17. The line: Dim custTables As DataTable = test.Tables.Add("CustTable") is adding a table with the name "CustTable" to your dataset. If you run through this code twice, you'll be trying to create a table that already exists in the dataset. That's your error. What do you expect the following line to do: OleDbDataAdapter.Fill(test) You need to create an instance of OleDbDataAdapter, set it's sql to something like "SELECT * FROM Table1" and THEN call Fill. As far as I can see from your code, the object cmd isn't needed. You create a command object but don't set any properties and it's never used (hopefully a compiler warning if it's turned on). Maybe you thought you would fill the dataset from a command object? Can't be done... -Ner
  18. I don't think they'll release them, but that's just a guess. They certainly won't review the items you missed or anything like that. If you have $100-$150 (not sure of the current price), Transcender makes practice tests that are very close to the MS exams, sometimes a bit harder. They usually come with three practice exams. If you can pass all 3 then you should have no problem passing the real exam. If you do go with Transcender, I suggest the following: 1. Take the first exam cold - don't study. See how close you are, look at the results and concentrate on any area you did bad in. 2. Retake the first exam and make sure you pass with a reasonably high score. 3. Take the second exam as in step 1 and 2. If you do the above, by the time you take Exam 3 you'd better be passing it on the first try. If you don't, it might be a sign that you need some more real world experience (what the exams are *supposed* to measure). The Transcender used to put references into the MS documentation as well. So for each question/answer, they give a full description of why the right answer is right and the wrong answer's wrong and references to look at. It's a GREAT way to quickly learn a lot about .NET, even if you don't want to take the exam. But you have to be willing to read a lot as you go through the tests. -Ner
  19. Weird indeed :) I used to use the T-SQL syntax in SQL Server (in version 6, and a bit in version 7) and loved it. Now that I've gotten the hang of the ANSI standard, well... jury's still out. I still miss the convenience of the T-SQL code (looks cleaner to me), but the ANSI version is nice (just harder to line things up and I'm an anal "keep the code clean looking" kinda guy). -Ner
  20. First off, this thread is REALLY old - you might as well create a new one with a question. Second, why not use the BringToFront, SendToBack methods? -Ner
  21. Is the string comma delimited, or just a bunch of digits? If it's like "1, 4, 123, 9, 456" then you could use the Split method and then loop to find the max. If the string looks like "1458273" and you want to find the biggest digit, then loop through the chars of the string to find the max. -Ner
  22. Nerseus

    ToString

    What are you trying to do, Jay1b? If you have an int and want to format it, use this: Dim i As Integer i = 123 Dim s As String = i.ToString("n00") There are various codes you can pass to ToString, depending on how you want the formatting. If you have a string and you're trying to convert to an int, then try this: Dim s As String = "123"Dim i As Integer Dim i As Integer = Convert.ToInt32(s) -Ner
  23. I think you may have it working now, but I would suggest this anyway: Don't put any of the "if closing..." type code in the Cancel button's click event. Normally a cancel button will have just Me.Close() and the closing event will do the logic (usually just what dynamic showed). Also, it makes handling the "X" a lot easier since all the code is in one spot. -Ner
  24. If you're using the Project Template to get a D3D app going, simply add this to the constructor of GraphicsClass: startFullscreen = true; Build the default D3D project with a teapot (select New Project, select the DirectX template project and choose Direct3D (the default) and add a teapot (also the default)). You'll have a number of files, including D3DMesh.cs. That's the main form (the form that will get called by Application.Run) which inherits from GraphicSample - a really nice class provided by MS. The base form is in d3dapp.cs, which contains the protected variable startFullScreen mentioned above. Since the inherited form GraphicsClass contains that variable as protected, you can change it's value to true and voila! Fullscreen app with one line of code :) To see what's going on when you change that flag, you'll have to walk through a TON of EXCELLENT code in d3dapp.cs. I would strongly suggest looking through as much of that code as possible. -Ner
  25. The exact opposite is true. ANSI standard SQL looks like: SELECT * FROM Table1 INNER JOIN Table2 ON Table1.Col1 = Table2.Col1 LEFT OUTER JOIN Table3 ON Table1.Col1 = Table3.Col1 The T-SQL version (Microsoft SQL Server specific): SELECT * FROM Table1, Table2, Table3 WHERE Table1.Col1 = Table2.Col1 AND Table1.Col1 = Table3.Col1 If you use ANSI standard you're more "standard" but it's a bit harder to read. You can do a little bit more with it, since on OUTER joins you can put more than one expression in the ON portion (...ON Table1.Col1=Table2.Col1 AND Table1.Col2 = 5). If you did the same thing in the WHERE clause (still using ANSI sytax for the join), the OUTER might not return rows if the WHERE clause didn't hit. It's hard to explain, but it's a little above your original question anyway :) -ner
×
×
  • Create New...