Closed FrankBerrocal closed 1 year ago
I will create my first code in a ConsoleAPP. I will not waste time trying to go to Docker, I have ASP options and I cannot wast time trying to implement something not developed yet.
Idea, test with Google Datastore. Now, test locally.
Connection created.
// Build connection string
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
builder.DataSource = "localhost,1440"; // Port should be indicated. In a container, the same.
builder.UserID = "sa";
builder.Password = "myPassw0rd";
builder.InitialCatalog = "master";
// Create a sample database Console.Write("Dropping and creating database 'SampleDB' ... "); String sql = "DROP DATABASE IF EXISTS [SampleDB]; CREATE DATABASE [SampleDB]"; using (SqlCommand command = new SqlCommand(sql, connection)) { command.ExecuteNonQuery(); Console.WriteLine("Done."); }
StringBuilder sb = new StringBuilder(); sb.Append("USE SampleDB; "); sb.Append("CREATE TABLE Employees ( "); sb.Append(" Id INT , "); sb.Append(" Name NVARCHAR(50), "); sb.Append(" Location NVARCHAR(50) "); sb.Append("); ");
NOT WORKING I am not able to create the table. WHY? this is an example from the internet. This is the same element I tried to create during last session.
Changed the name of the database, however keeps creating SampleDB. The file running is not the one I am working with
That last step made me check the code. I analyzed the elements required by the program:
Table has been created.
I have checked the code, and created an abstraction. This can lead to an object during implementation.
String sql = "";
StringBuilder sb = new StringBuilder();
sb.Append("DROP DATABASE IF EXISTS [Ulysses];");
sb.Append("CREATE DATABASE [Ulysses];");
sql = sb.ToString();
using (SqlCommand command = new SqlCommand(sql, connection))
{
command.ExecuteNonQuery();
Console.WriteLine("Done.");
}
sb.clear(); //to work with the next command
I have been able to implement and standardize all the examples on the reference page https://www.microsoft.com/en-us/sql-server/developer-get-started/csharp/macos/step/2.html
This means all the functionality is available, reflected in SQL, and also, generalization has been conceptualized.
One important element is that the UML conceptualization is developed from the point of view of the user, but since I am working with multiple layers, each one involves a different diagram.
For example, I have the Class diagram for the entities, which is backed up by an ER diagram. And also in C#, another diagram should represent the objects handling all SQL objects, displays, and queries.
With LA3, connections to a Database were set.
DML was non-responsive.
Based on this example: