Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USING System;
- USING System.Collections.Generic;
- USING System.ComponentModel;
- USING System.DATA;
- USING System.Drawing;
- USING System.Linq;
- USING System.Text;
- USING System.Windows.Forms;
- USING System.DATA.SQL;
- USING System.DATA.SqlClient;
- namespace LearnOnline
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- private void btnSubParent_Click(object sender, EventArgs e)
- {
- string myConnection = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Grant\Documents\College Work\FD Computing\Year 2\APD\LearnOnline\LearnOnline\Database1.mdf;Integrated Security=True;User Instance=True";
- SqlConnection conn = NEW SqlConnection(myConnection);
- try
- {
- conn.OPEN();
- }
- catch (Exception)
- {
- MessageBox.SHOW("Connection Failed");
- }
- string username = txtboxPUser.Text;
- string password = txtboxPPword.Text;
- string sqlquery = ("SELECT * FROM Parent WHERE Username = '" + txtboxPUser.Text + "'");
- sqlquery = "INSERT INTO [Parent] (Username, Password) VALUES ('" + txtboxPUser.Text + "','" + txtboxPPword.Text + "')";
- SqlCommand command = NEW SqlCommand(sqlquery, conn);
- command.Parameters.AddWithValue("Username", username);
- command.Parameters.AddWithValue("Password", password);
- command.Parameters.Clear();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement