Question:
How do you program a database (console programming) c#?
RK07
2010-01-28 16:18:08 UTC
I'm sorry about this. I'm a newbie to programming, and I was set to do a database of some sorts in c#. This application has to run on the CMD or 'console' as the progam calls it. Anyway, I was trying and came up with this.

class Program
{
static void Main(string[] args)
{
string sName;
Console.WriteLine("Write your name:");

sName = Console.ReadLine("Name:" + sName);

Console.Read();
}
}

It doesn't work however. Theoretically, you should be able to type in your name and other data and the program would later show it all, together. My main problem is that I keep getting the error message "Cannot implicitly convert string to void" or "No overload method for ReadLine takes '1' arguments." Can you help me?
Four answers:
Mantis
2010-01-28 16:23:48 UTC
The specific fix for the problem you are seeing is to change your readline to this:



Console.ReadLine(sName);



Drop the prompt. You can include the prompt in a writeline statement.



Trying to do a database-style thing is a little tricky and you'll want to get basic file I/O and arrays under your belt first. But it can be done.



Good luck and keep coding.
Snail Fan
2010-01-28 16:25:40 UTC
The Console.ReadLine method only reads what you type in the console. Try the program like you have it, but just put Console.ReadLine() as I wrote it and get rid of Console.Read. If you want to display the name you just read, you could add a line like Console.WriteLine("Hello, {0}", sName); beneath the ReadLine call. I hope this helps and have fun with C# (it's a fun language).
2010-01-28 16:32:44 UTC
Console.ReadLine() doesn't take any arguments. To accomplish what you want you have to do is something like:

Console.Write("Write your name: ");

string name = Console.ReadLine();



ReadLine is an input function, Write and WriteLine is an output function, you can't output in a readline statement. As for the database part you might want to look at the ADO.Net and the System.Data namespace, it contains the classes you need to accomplish an in-code database. Useful classes are:

DataTable <- represents a table of data.

DataRow <- represents a row of data in a datatable.

DataColumn <- represents a column in a datatable.
2016-09-30 05:09:21 UTC
no longer anymore, at one time C++ became into in basic terms an extension of C. on account that then, C has replaced, and so has C++. although that being suggested that is commonplace for a similar application to hold at the same time the two C and C++. the tactic is a similar, yet there are basically some modifications int he libraries which you prefer the compiler to link to.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...