Jump to content

madknight3

Member
  • Posts

    1,786
  • Joined

  • Last visited

Everything posted by madknight3

  1. Note that ToShortDateString is culture specific so it won't format the same for everyone. For example, ToShortDateString uses a "yyyy-MM-dd" format for me. DateTime.Now.ToString("yyyy-MM-dd") == DateTime.Now.ToShortDateString() // true for me
  2. I think you should just be able to cast from the reader and not have to go through a string conversion at all. // Cast instead of using ToString DateTime sdate = (DateTime) reader2["Date"]; // Then format it as desired. Example: string formattedDate = sdate.ToString("dd-MM-yyyy");
  3. There are multiple options you can use to share information between pages. Here are some that come to mind. Submit a form Add the value to the url as a query string Persist the data somewhere the page can access Database Cookie Session Use websockets
  4. Thanks everyone. I passed along the info and she's really digging the 2 in 1s so she's deciding between the Inspiron and the Spectre x360
  5. Hi, I'm looking for a fast and lightweight Windows laptop for a friend of mine. Doesn't have to be the smallest/thinnest thing around, but I'd like to keep it towards that end of the spectrum. Main uses: Office work web browsing photo editing Here are the minimum specs I'm leaning towards 15" IPS display (1080p or 1440p should be fine) 8 GB RAM 256 SSD A few ports are always nice (some USB and something to connect a monitor to) Long battery life isn't critical but is a bonus Doesn't need dedicated graphics or any special features (touchscreen, fingerprint scanner, etc). Don't care about webcam/mic quality. Don't have a budget in mind. Just going for the lowest price that can hit the target I suppose. Here's a few I've been looking at but am open to suggestions Dell Inspiron 15 7000 2-in-1 ($1099 model) Dell XPS 15 ($1799 SSD model although likely getting too expensive when the other cheaper options seem viable) Lenovo Yoga 710 15" ($1299 model)
  6. It's hard to know exactly what's wrong without seeing your data. The best way to know for sure is for you to post some test data and the correct order you want the data to be displayed. I'll give a couple guesses below though. It could be that what you really want is to ORDER BY SenderID and not UserID. Example. Given this data SenderID, Subject, UserID ------------------------- 1, "Subject 1", Scott 2, "Subject 2", Admin 3, "Subject 3", Betty Using ORDER BY UserID will sort it like this 2, "Subject 2", Admin 3, "Subject 3", Betty 1, "Subject 1", Scott Since you aren't selecting UserID it could be that it just looks out of order. 2, "Subject 2" 3, "Subject 3" 1, "Subject 1" Using ORDER BY SenderID will return this 1, "Subject 1", Scott 2, "Subject 2", Admin 3, "Subject 3", Betty Or it could be that because you're using a string and not a number for your UserID column, it's sorting lexicographically and it's not doing what you want. Example. Say you have this data UserId ------ Admin1 Admin2 Admin100 You might think "ORDER BY UserID" will result in the above order. However, it will actually result in this order. Admin1 Admin100 Admin2 Because the database doesn't look at the numbers at the end of the UserID as an integer.
  7. In C#, the backslash (\) is used to allow characters that have a special meaning to be a part of the string. Here's some example of escape sequences. You either need to escape your backslash (\\) SqlConnection cn = new SqlConnection("Data Source=Dell-PC\\SQLEXPRESS;Initial Catalog=employee_db;Integrated Security=True"); Or use a string literal (@ sign in front of string) which treats each character as it's written and doesn't require the use of escape sequences. SqlConnection cn = new SqlConnection(@"Data Source=Dell-PC\SQLEXPRESS;Initial Catalog=employee_db;Integrated Security=True"); Side note for string literals, double quotes are added into it like so var s = @"\this is a ""test"" string\"; var s2 = "\\this is a \"test\" string\\"; // Both of the above store // \this is a "test" string\ Also, note that you're missing a parameter for @npid SqlCommand cmd = new SqlCommand("UPDATE Posts SET description=@des WHERE id =@npid"); cmd.Parameters.AddWithValue("@des",textBox1.Text);
  8. It often helps when you also include the exact error message when you post issues. The variables sql2 and sql aren't matching up. Could that be your issue? // ... string sql = "select COUNT(*) from Employee where EmpID='" + eid + "'"; //count records that tally user input // ... cmd = new SqlCommand(sql2, cn); // ...
  9. Just in case OP gets confused, for their current query where they are getting the count, and for any query that returns a single value, ExecuteScalar is the best option. So they are correct in that regard. It's overkill to use anything else. Also, note that there are pros and cons to the different readers (performance, memory usage, convenience, etc). In some cases, you'll want to use SqlCommand/SqlDataReader over SqlDataAdapter and vice versa. Here are some references StackOverflow: What is the difference between ExecuteScalar, ExecuteReader and ExecuteNonQuery? StackOverflow: When to use ExecuteScalar,ExecuteReader,ExecuteNonQuery? StackOverflow: SqlCommand or SqlDataAdapter? StackOverflow: SqlDataAdapter vs SqlDataReader
  10. You use parameter @xy in your query and then add parameter @x to the command. SqlCommand check_User_Name = new SqlCommand("SELECT COUNT(*) FROM [Employees] WHERE ([emp_ID] = @xy)", cn); check_User_Name.Parameters.AddWithValue("@x", textBox1.Text); You also mention this but use the greater than operator instead of the equals operator if (UserExist > 0)
  11. I follow what's going on in the .NET ecosystem as it's relevant to my job but outside of that I don't follow anything too closely. I like to have a general idea of the landscape but I don't need to know the specifics of everything. At the moment I'm just focused on improving my skills as a software developer in general. Again, I spend most of my time within the .NET ecosystem since that directly impacts my current job. If I was planning on leaving my current job, ideally a lot of the knowledge I'm gaining will transfer to other languages/frameworks as well if I ever decided to do something outside of the .NET ecosystem.
  12. 1. I don't follow the different languages/frameworks closely enough to know which is most in demand. I don't worry too much about that kind of thing. For example using indeed.com (however good that site is) Searching ".net" gives around 3200 results for New York City and 1400 for San Francisco. Searching "java" gives around 5500 results for New York City and 4050 for San Francisco. Searching "php" gives around 1500 results for New York City and 1230 for San Francisco. Searching "python" gives around 4200 results for New York City and 3900 for San Francisco. etc Now these aren't exact numbers and they are only from one site. Some of the matches may not be accurate. Some of them will be for positions beyond your experience level. etc. My point is, there are lots of jobs around for lots of languages and it varies from place to place. 2. MySql, Sql Server, and Orcale are all relational databases (there are others as well). SQL is the standard language for interacting with all of them, however they add their own stuff on top of it. So there are some differences. Don't worry too much about that though, the basics are all pretty much the same. 3. If you end up choosing to stick with C# and .NET, then that's my recommendation for that. If you choose to go outside of .NET then it won't apply to you. 4. It's always good to update if you don't have a reason not to. That way you're sure to keep up with all the latest improvements. Visual Studio 2017 Community is the most up to date. You can run both versions of Visual Studio side by side though so you don't need to uninstall your version to install the new version. Also, in general choose the Community edition over the Express edition unless you have a specific reason not to (like license requirements). The community edition has more features and isn't split up into multiple pieces like the Express editions. Again, this only applies to .NET development. Visual Studio can be used for other languages as well but it's not necessarily the best option. Jetbrains, Eclipse, and many other options exist. 5. I'm a Canadian who's never had much interest in living in the US so I've never looked into the big tech cities there. Through looking at job sites, news/blog articles, talking to people in the industry, etc you should be able to find some more specific info. I would expect many different languages to be in high demand though. 6. We build software that other companies use that help them manage their business. It includes software to manage their employees, accounting, documents, communication, etc and is tailored more towards their specific use cases. So it's mostly a mixture of software that they use internally and some of which is used by their customers. It's not something that the general public would use and its nothing social media, gaming, or entertainment related. 7. For web development, we have HTML, CSS, and JavaScript on the front end. It's the most common setup for front end web development in general. For desktop and mobile applications, .NET stuff tends to use a XML based language, like XAML.
  13. You only need to know one server side language/framework. In general that might mean your are limited to finding jobs for that specific language/framework but for a popular language/framework that's still a large number of jobs. With that said, it's also not a bad thing to learn more than one. The more languages/frameworks you know, the more jobs you can confidentially apply to. It can also making picking up a new language/framework easier, so you may even feel like applying for jobs in languages/frameworks you've never worked with before. If you can demonstrate you're a good web developer with the languages/frameworks you know and that you can get up and running with a new framework fairly quickly, then that may still land you the job. Even if you choose to learn more than one language/framework, I would still choose one to focus on and know really well. How you choose that language/framework is up to you. You can choose the language/framework you like the most. You can choose the language/framework with the most job postings in the areas you'd like to work. Etc You'll want to learn some SQL for any option you choose since SQL is the default language for querying a relational database (MySql, Sql Server, Oracle, etc). Every language (Python, C#, etc) has APIs for interacting with databases but they are just executing SQL against the database. Sometimes you're writing the SQL that these APIs execute (usually in a hardcoded string), sometimes you're not and the API is generating SQL for you behind the scenes (like with Entity Framework and LINQ), but ultimately it's still SQL and it's good to know. Yes. The primary framework for C# and .NET backend web development is ASP.NET There are four main options for ASP.NET development. ASP.NET Web Pages ASP.NET Web Forms ASP.NET MVC (up to version 5) ASP.NET Core Here's an overview ASP.NET Web Pages is not something I know much about so I'm not sure how much it's used within companies compared to the others. I've never really considered it to be a contender with the other three mentioned, but again, I just don't know much about it or it's use. ASP.NET Web Forms is not very popular for new applications these days, although there are still some companies using it for this, but a lot of older applications that were written with it are still being maintained and updated. Doesn't hurt to know a bit of this if you don't mind working for those companies. ASP.NET MVC is probably currently used the most. This is likely where you should spend most of your focus. I'd also include Web Api in this as it's the most common way to build HTTP APIs in .NET ASP.NET Core is a new rewrite of the ASP.NET framework that was released in 2016 and is continuing to be worked on. Adoption is growing but it's still a baby compared to the 10+ year history of Web Forms and MVC. However this is probably where the future is headed for ASP.NET so I would recommend learning a bit of it as well. TLDR: I'd spend most of your time on ASP.NET MVC 5 and Web Api 2 to start and then get into ASP.NET Core as well. ASP.NET Web Forms is optional. Side note: Pluralsight has a lot of video courses for learning the different ASP.NET options. Sign up for the free Visual Studio Dev Essentials program and some free months of Pluralsight. PHP is a very widely used language for web development. Possibly the most widely used but I don't have any numbers. Like you said, every company is different. If you have specific companies in mind then find out what they use and learn those. If you don't have any specific companies in mind, but have specific locations in mind, then you may want to look into job postings for those areas to see what languages will give you the best chances. If you don't care about either of the above, then maybe just try to find a job with your favourite languages/frameworks first and if that isn't working out try to expand later. As far as I know, there's no shortage of jobs for each language you mentioned above (Python, .Net, Ruby, Java, and PHP). I'm working for a small company that does a variety of .NET development (web apps, desktop apps, mobile apps). Because the team is small, I work on everything. I never set out to be a "full stack" developer, or any type of developer, I just happened to end up doing it. I primarily work with VB.NET, C#, JavaScript and SQL with some HTML and CSS in there too (though another guy at the company tends to do most of the CSS work).
  14. Stick with C++ since it's what you're using. There's not much point in going back to C when you need to use C++. If you need to go back to basics on a topic, do so with C++ If that's the case then that's something you may want to practice doing. It depends. If it's important for your current course, as you implied above, then probably. At least to the extent that you need it. If you already know C well enough for this course then you may not need to do much/any practice with it and just focus on C++. Whether or not you choose to continue learning/improving with C or C++ after your course depends on what you want to do career/hobby wise. There are situations where you would still want/need to use C over C++ and vice versa. For example When to use C over C++, and C++ over C? Why would anybody use C over C++? C or C++ (or both) may be critical to what you want to do. Or you may be able to forever walk away from those languages at the end of your course and still have an amazing career. It doesn't hurt to know them though. Yes, the object oriented programming principles are the same regardless of language. The specifics of how they're done can be different depending on language syntax/features, and I expect there may be a few OOP things that C++ will let you do that Java won't, however the general concepts don't change. In general, no, it shouldn't be too difficult to learn Java given that you already have experience with C and C++. However if you're completely new to OOP, then that can make it difficult. It depends on how easily you grasp the subject. Some people have issues learning and understanding OOP concepts, some don't. Whether you end up liking Java or not is a completely different question though. Projects are great for practicing what you already know and through doing them you are likely to run into things you don't know how to do. Tutorials, books, videos, etc are great for learning about specific topics however they tend to be limited in showing you how to apply what you're learning. They usually show you some examples but they can't cover everything. You'll want to do both.
  15. Unfortunately I don't have anything specific I can recommend to you, however AlternativeTo and Slant can sometimes be handy for suggestions. You usually have to do more research into the options yourself but it's a place to start.
  16. I recommend starting with this free video course for getting started with C# and .NET - Microsoft Virtual Academy: C# For Absolute Beginners edit: I just saw the C++ tag. For that they have this free course - Microsoft Virtual Academy: C++: A General Purpose Language and Library Jump Start However it doesn't seem to be recommend for beginners so another option is to use Pluralsight (get three free months with the Visual Studio Dev Essentials program) and check out their C++ path. Side note: You should be able to follow these older tutorials with the new tool versions (like the latest version of Visual Studio instead of the older version they might be using).
  17. I believe XCode is the primary IDE for developing iOS apps. In terms of languages, it would probably be beneficial to learn both Swift and Objective C. On a side note, looking into iOS development with C# and Xamarin may also interest you. I wouldn't ignore native development, but it's something you may like to consider as well.
  18. I wouldn't be surprised if Microsoft's Sql Server is more common when working within the .NET ecosystem though. It certainly doesn't hurt to learn to work with MySql, but I probably wouldn't use it over Sql Server in .NET unless I had a specific reason to do so. Given @happyteddybearwithnobeard is already using Sql Server in their project, there's probably no need for them to switch. But it doesn't hurt to explore your options.
  19. I recommend Automate The Boring Stuff. It's a free online book (or you can buy it) with videos to accompany the chapters. The official documentation is really useful as well so get familiar with that once you've got the basics down (they also have tutorials as well).
  20. First, in Form1 you're missing the constructor with the call to InitializeComponent(). That's why when you run your application nothing is being displayed on the forms. public partial class Form1 : Form { public Form1() { InitializeComponent(); } // rest of code } Second, don't modify the designer file (Form1.Designer.cs) unless you need to. It's meant to hold the code that's generated from Visual Studio designer. Instead, you use the code behind file (Form1.cs - ie: the file where you put your SQL code). I noticed that all your event methods were in the designer file instead of your code file. I don't know if it was something you did but I manually went through and moved the events to the code file. Third, your call to Close() at the end of button4_click is closing your whole form. This may be what you want, but I just wanted to make sure. protected void button4_Click(object sender, EventArgs e) { // ... Close(); // This closes the windows form, not a connection or anything. In case that's what you intended. } } I think I've fixed up your project for you and added in some code for the sql method to hopefully get you on the right track. Here are the attached files. VisualStudio2.zip
  21. You need to understand that a CS degree is not meant to make you a software developer, so don't expect it to. CS is a very large field that covers both programming and non-programming aspects. If you have the opportunity, do internships. There's no better way to get industry and software development experience before you finish your degree. It's worth pushing your graduation date for an internship (in my opinion). A lot of companies (including the big ones like Google, Microsoft, Facebook, etc) do data structure & algorithm focused interviews, so be sure to keep that as a high priority if you want to be able to get with those companies. There's so many places to find advice online for getting internships, getting started with open source contributions, conquoring the interview, etc so search around. Google. Check useful subreddits (like r/learnprogramming/ and r/cscareerquestions/). Glassdoor Interviews. etc
  22. I don't think this code will do what you want it to do multiTimeStopwatch.Start(); //Start the threads and make the benchmarking happen! pyThread.Start(); trigThread.Start(); multiTimeStopwatch.Stop(); That's just timing how long it takes to start up the threads. It doesn't take into account how long the threads run for. You probably want something more like these answers describe - StackOverflow: How to wait for thread to finish with .NET? edit (to answer your original question): So regarding the printing issue, I think it's because multiTimeStopwatch.ElapsedMilliseconds is zero because there's not enough precision to measure something that fast. Which means you're dividing by zero later. Here's some code to explain. class Program { static void Main(string[] args) { double multiTime = 0; double x = 1 / multiTime; Console.WriteLine(x); // prints weird character // If you were using integers it would throw an exception. // However double has the notion of Infinity and NaN so it doesn't throw an exception bool b = double.IsInfinity(x); // is true Console.WriteLine(b); } } Side note, some programs may properly print out an infinity character. Like LINQPad did when I tested with that. Another side note, if ElapsedMilliseconds isn't enough in the future you may be able to get a value from ElapsedTicks - StackOverflow: How do you convert Stopwatch ticks to nanoseconds, milliseconds and seconds? (I've never looked into the accuracy of this though)
  23. Sounds like you have an error with your SQL statement. Make sure the string that's created is a valid query. You should be able to set a breakpoint and view the query string after it's assembled. I also recommend parameterizing your queries to protect against SQL Injection and to have to worry less about the format of your values (don't have to manually deal with quotes and stuff). SqlCommand sc=new SqlCommand("insert into TabelaKlienci values(@Column1,@Column2,@Column3,@Column4,@Column5,@Column6)",con); // If you want to explicitly declare the data type sc.Parameters.Add("@Column1", SqlDbType.VarChar).Value = variableForColumn1; sc.Parameters.Add("@Column2", SqlDbType.Int).Value = variableForColumn2; //etc // or if you don't sc.Parameters.AddWithValue("@Column1", variableForColumn1); sc.Parameters.AddWithValue("@Column2", variableForColumn2); // etc // You can name the parameters anything you like, I just used @Column1, etc because I don't know what your columns are named They are optional, although I think it's a better practice to use them.
×