Creare Baza de Date Din Cod:: Public Static Void New String New
Creare Baza de Date Din Cod:: Public Static Void New String New
Creare Baza de Date Din Cod:: Public Static Void New String New
try
{
myCon.Open();
cmd.CommandText = "ALTER TABLE [dbo].[Localitati] ADD CONSTRAINT [FK_Judete_Localitati] FOREIGN KEY([Judete_FK]) REFERENCES [dbo].
[Judete]([id]) ON DELETE CASCADE";
cmd.ExecuteNonQuery();
Console.WriteLine("Realatie creata!");
myCon.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
INSTERT
cmd.CommandText = "INSERT INTO Judete(id,Denumire,Suprafata) VALUES('" + jud[i].id + "','" + jud[i].denumire + "','" + jud[i].suprafata + "')";
cmd.ExecuteNonQuery();
DELETE
static void DeleteJud()
{
Console.WriteLine("Dati id-ul judetului: ");
int idjud = int.Parse(Console.ReadLine());
SqlConnection con2 = new SqlConnection(@"Data Source=ADMIN\SQLEXPRESS;Initial Catalog=Romania; Integrated Security = True");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con2;
con2.Open();
string judname = "";
SqlDataAdapter da = new SqlDataAdapter("SELECT id,Denumire FROM Judete ", con2);
DataSet ds = new DataSet();
da.Fill(ds, "Jud");
bool match = false;
foreach (DataRow row in ds.Tables["Jud"].Rows)
if (idjud == (int)row["id"])
{ match = true; judname = row["Denumire"].ToString(); }
if (match == true)
{
cmd.CommandText = "Delete FROM Judete WHERE id=" + idjud + "";
cmd.ExecuteNonQuery();
Console.WriteLine("Judetul " + judname + " a fost sters");
}
else
Console.WriteLine("Judetul nu a fost gasit!");
con2.Close();
}
STIVA :
public class Stackp
{
public const int MaxSize = 10;
public string[] items = new string[MaxSize];
public int currentIndex = -1;
public Stackp()
{}
currentIndex++;
items[currentIndex] = item;
}
return item;