Jump to content
Xtreme .Net Talk

Winston

Avatar/Signature
  • Posts

    273
  • Joined

  • Last visited

Everything posted by Winston

  1. Hey guys, ok i have so many questions since i'm a total newbie to SQL server. Firstly, i posted this code on another forum we ended up solving it, but i need bit more explanation: String dbpath = Path.Combine(Application.StartupPath, "Database1.mdf"); String conn = @"Server=.\SQLExpress;AttachDbFilename=" + dbpath + ";Database=database1;Trusted_Connection=Yes;"; SqlConnection con = new SqlConnection(conn); con.Open(); SqlCommand comm = new SqlCommand("SELECT * FROM Student", con); SqlDataReader reader = comm.ExecuteReader(); while (reader.Read()) { MessageBox.Show("Retrieved ID:" + reader["ID"] + ", Name: " + reader["Name"]); } So firstly the initial problem was i couldn't even make it past the connection string itself, I kept getting this exception: Directory lookup for the file "C:\Documents and Settings\Winston Pang\Desktop\WindowsAppplication2\WindowsApplication2\bin\Debug\Database1.mdf" failed with the operationg system error 5(Access is denied.). Could not attach file 'C:\Documents and Settings\Winston Pang\Desktop\WindowsAppplication2\WindowsApplication2\bin\Debug\Database1.mdf' as database 'database1'. I didn't do anything majorly complicated. SQL Express was brand new installed. I just whipped up a new C# project, added a button and added a new .MDF file, created a Student table with 3 fields, then made the code above, and got the exception. There was a hacky fix, someone told me to use user instance = true in the connection string, that fixed it, but what does this attribute do, i heard it's only in the SQL Express edition? And is this the only way you conenct locally to a .mdf file? I also want to know what the Database and Initial catalog values come from for the connection string, are they arbitrary values you make up? Also, finally, if i wanted to set a user id and password on the .mdf file, how does that work? Thanks for everyones help!
  2. Well from within the container class, it's just simply this.Control.Add(panel1); panel1, is already defined, etc, just couldn't be bothered typing the rest of the code. The panel1 gets added fine, but when u drag the container control onto a form in design time, the panel1, cannot be selected from within the form. I've sort of figured out and noticed why, but i think the apparent reason is, the form itself has to create the panel and store it inside the form, and then pass just the reference of the panel to the control, well at least that's what i'm noticing from the TabControl.
  3. I'm writing a custom tab control. I'm inheriting from ContainerControl, the problem i'm facing is, during design time when u drag a Panel or any other control into the container, you can select the control inside the container, but when i add the control from within the class that dervies from ContainerControl. The controls cannot be selected during design time, is there any reason, how can i fix this? Thanks.
  4. Alright guys i'm stumped, i've been searching multiview examples online and i get the concept, however since my multiview is embedded inside the loginview control, i have no way of accessing the multiview control via code, it's not listed in intellisense or anything and manually typing it doesn't work, for some reason multiview isn't exposed, any help?
  5. Ahhh crap, so there is no way of achieving the design time effect through dynamic code?
  6. this might sound weird but say you add a Panel within a panel, and you can drag controls into the inner Panel. This works great, however, i'm making a custom control where the main entire thing is inherited from Panel and there's lots of painting, then in the constructor of this inherited panel i create another panel and position it etc, and do this.Controls.Add(panel); So once compiled i add it to a project, but when i try to drag a new control say a button into this container the button will only go into the primary panel but not the inner panel i dynamically created and added in the constructor, what is the difference from dynamically doing so and allowing people to drag controls into the inner panel as opposeed to doing it during design time? Hope someone can help, thanks!
  7. Been trying to use these const int WM_MOUSEHOVER = 0x02A1; const int WM_MOUSELEAVE = 0x02A3; const int WM_NCMOUSEMOVE = 0x00A0; const int WM_NCLBUTTONDOWN = 0x00A1; but none of them work!
  8. Hmmm ok that code above works, yay, but how do i detect for mouse leave and mouse click?
  9. I've done this before, basically you can add the file you want as a resource file into the solution, you gotta set it to compile in the exe, when needed, you can open the file as a temporary stream and write it to disk, as if it's copied, i'd advise you to keep all these templates as a class library so that way when u need to update them, you just update that particular dll.
  10. That's alot of effort! lol i was anticipating theres a special way to achieve it, via turning on some attributes and overriding other specific methods :S, i would of thouight the IDE offers a better design time support for control designers.
  11. Yes, ihave, lots of third party controls like toolbar ones, also, the given TabControl in provides this.
  12. Hmmmm not quite, what i'm looking for is, like say you create a new UserControl project, and inside this, you wire up Mouse events, so that it will change some boolean value or whatever, which will be detected in the paint event, so when you hover over the control the control should paint differently, however, these hover events don't appear to be active when the control is in design time, i.e. when you drag the control onto a new solutioon hovering over the item doesn't do anything.
  13. bump! anyone with any ideas?
  14. How do i offer interactive design time support for custom made controls? I'm doing it in VS2K5, basically when i mean design time i mean like, when u hover over the control, any mouse events etc u have wired to the control will work, because the control imade when hovered it paints differently. Also, other design time support like, if u add a panel/user control inside the user controls, during design time in the IDE, users can seperately select the embedded panels/user controls to change it's propertys accordingly.
  15. So would this automatically add the numbering? i.e. the image i posted, and can i hardcode a limit of how many items per page? Thanks for your help.
  16. Hey guys i'm trying to achieve this in ASP.NET 1.1, dynamically populating my page with webcontrols into a table, however, i only want the page to have like 5 webcontrols in the table in each page, and i want to have this little page numbering like most website does, see attachment, so how do i achieve this, i'm a n00b at this, thanks guys.
  17. Ummmm this link tag is for my stylesheet, i should of stated earlier, sorry.
  18. Hey does anyone know how i can dynamically change an attribute of tag, in particular i want to change the href attribute in the link tag, any ideas anyone? thanks.
  19. I've been wondering some sites who uses asp.net have just one single page like main.aspx, that's it, and they use query strings like ?page=about my question is, how do u implement this in asp.net and how does it work in general, like is it just one .aspx file ur dealing with and u populate the page based on what the query string is? :S... like is this a feasible way of implementing i mean what about static contents which remain the same at times, for example the about page or contact page. Wouldn't you have a big switch/case statement? select case page case "about" 'dynamically load contents.. end select is that how it works? please give me some insigt into this way of implementing sites, thank you :)
  20. Ummmm create a menu item and put the text as a hyphen i.e. "-" (without quotes) That's how you createa seperator in VB, i think it applies to C# as well.
  21. First of all Windows 2000 does not support visual styles, so it won't render any visual style layers onto your controls. Second of all do not use the Application.EnableVisualStyles() call, because it causes numerous problems, it's a buggy method. Stick with the manifest file for now, i think they rectified this issue in Whidbey.
  22. lol believe me this is quite non-trivial to do, it's easy to show it in the property grid it's just a simple attribute, not at home don't have the IDE in front of me, i think it's DesignTimeSerialization? someone will correct me, but that will only enavle you to show it in the property grid, it will probably add the items correctly but the hardest things are using TypeConverters to get the code generators generating code for the item in the collection.
  23. I'm like realtively new to server side wbe designing, in a traditional html site, you'd just create the layout and just use that as the template and copy and paste the html file and change it based on the page. But i know that in ASP.NET you can allow the layout to be shared and consistent amongst all pages, or some people just have one single .aspx file and it can change so differently. Can anyone point me to the right topics i need to read about in order to achieve that? Thanks.
  24. I've been trying to get this to work, but it doesn't populate or it doesn't show up in the table, what am i doing wrong? this.Table1.Rows[0].Cells[0].Controls.Add(new testControl());
  25. Ok please refer to the Paint Mockup. The Blue Rectangles represennt for example a particular entry, like e.g. It's a Web Control that holds Some text fields and a image box, this would be customer Web Control, Now the question here is, Notice the Green area, that's where the contents will be displayed, now that area is like a table, now what i want to know is first of how would populate that table with the custom Web Control, and grab the data from a DB in insert it into the Web Control. That's my first question, second one is, notice in the screenshot i put, 1,2,3,4,5,6 > That's like how some website have other pages of the same items. How would i do that? Like say limit each page to have only 5 of those Blue Items and then force it to create a new one and re-populate another 5. Does anyone understand what i'm trying to get at? Thanks Heaps!
×
×
  • Create New...