Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
public static int ExecuteNonQuery(string sql)
{
string connectionString = "SERVER=DAUTSQL01.fremont.lamrc.net; Database=Visitors; User ID=VisitorDB; Password=9AbU5ApHa;";
SqlConnection connection = new SqlConnection(connectionString);
try
{
connection.ConnectionString = connectionString;
connection.Open();
SqlCommand command = new SqlCommand(sql, connection);
return command.ExecuteNonQuery();
}
catch (Exception a)
{
if (a.Source != null)
Console.WriteLine("IOException source: {0}", a.Source);
throw;
}
finally
{
connection.Close();
}
}
public void buttonSpeichern_Click(object sender, EventArgs e)
{
string connectionString = "SERVER=DAUTSQL01.fremont.lamrc.net; Database=Visitors; User ID=VisitorDB; Password=9AbU5ApHa;";
SqlConnection connection = new SqlConnection(connectionString);
InsertBesucher(connection);
}
public static SqlDataAdapter InsertBesucher(SqlConnection connection)
{
SqlDataAdapter adapter = new SqlDataAdapter();
SqlCommand command = new SqlCommand("INSERT INTO visitor_database (first_name, last_name, screening_result, license_plate, personal_document, fknation, fkcompany, fkcategory) " + "VALUES (@first_name, @last_name, @screening_result, @license_plate, @personal_document, @fknation, @fkcompany, @fkcategory)", connection);
command.Parameters.Add("@first_name", SqlDbType.VarChar, 75, "Vorname");
command.Parameters.Add("@last_name", SqlDbType.VarChar, 75, "Nachname");
command.Parameters.Add("@screening_result", SqlDbType.Bit, 1);
command.Parameters.Add("@license_plate", SqlDbType.VarChar, 50, "Kennzeichen");
//command.Parameters.Add("@personal_document", SqlDbType.VarBinary, max);
command.Parameters.Add("@fknation", SqlDbType.Int, 2);
command.Parameters.Add("@fkcompany", SqlDbType.Int, 2);
command.Parameters.Add("@fkcategory", SqlDbType.Int, 2);
return adapter;
}
public static int ExecuteNonQuery(string sql)
{
string connectionString = "SERVER=DAUTSQL01.fremont.lamrc.net; Database=Visitors; User ID=VisitorDB; Password=9AbU5ApHa;";
SqlConnection connection = new SqlConnection(connectionString);
try
{
connection.ConnectionString = connectionString;
connection.Open();
SqlCommand command = new SqlCommand(sql, connection);
return command.ExecuteNonQuery();
}
catch (Exception a)
{
if (a.Source != null)
Console.WriteLine("IOException source: {0}", a.Source);
throw;
}
finally
{
connection.Close();
}
}
public static SqlDataAdapter InsertBesucher(SqlConnection connection)
{
SqlDataAdapter adapter = new SqlDataAdapter();
SqlCommand command = new SqlCommand("INSERT INTO visitor_database (first_name, last_name, screening_result, license_plate, personal_document, fknation, fkcompany, fkcategory) " + "VALUES (@first_name, @last_name, @screening_result, @license_plate, @personal_document, @fknation, @fkcompany, @fkcategory)", connection);
command.Parameters.Add("@first_name", SqlDbType.VarChar, 75, "Vorname");
command.Parameters.Add("@last_name", SqlDbType.VarChar, 75, "Nachname");
command.Parameters.Add("@screening_result", SqlDbType.Bit, 1);
command.Parameters.Add("@license_plate", SqlDbType.VarChar, 50, "Kennzeichen");
//command.Parameters.Add("@personal_document", SqlDbType.VarBinary, max);
command.Parameters.Add("@fknation", SqlDbType.Int, 2);
command.Parameters.Add("@fkcompany", SqlDbType.Int, 2);
command.Parameters.Add("@fkcategory", SqlDbType.Int, 2);
return adapter;
}
public static int ExecuteNonQuery(string sql)
{
string connectionString = "SERVER=DAUTSQL01.fremont.lamrc.net; Database=Visitors; User ID=VisitorDB; Password=9AbU5ApHa;";
SqlConnection connection = new SqlConnection(connectionString);
try
{
connection.ConnectionString = connectionString;
connection.Open();
SqlCommand command = new SqlCommand(sql, connection);
return command.ExecuteNonQuery();
}
catch (Exception a)
{
if (a.Source != null)
Console.WriteLine("IOException source: {0}", a.Source);
throw;
}
finally
{
connection.Close();
}
}
public void buttonSpeichern_Click(object sender, EventArgs e)
{
string first = textBoxVorname.Text;
string last = textBoxNachname.Text;
int fkcategory = 1;
if (first == "" || last == "")
{
MessageBox.Show("Please ensure all fields are entered", "Error");
}
else
{
SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = @"SERVER=DAUTSQL01.fremont.lamrc.net; Database=Visitors; User ID=VisitorDB; Password=9AbU5ApHa;";
SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dataConnection;
dataCommand.CommandText = ("INSERT visitor_database (first_name, last_name, fkcategory) VALUES (@first, @last, @fkcategory)");
dataCommand.Parameters.AddWithValue("@first", first);
dataCommand.Parameters.AddWithValue("@last", last);
dataCommand.Parameters.AddWithValue("@fkcategory", fkcategory);
dataConnection.Open();
dataCommand.ExecuteNonQuery();
}
}