Visual Studio 2017

  • Thread starter Thread starter Thushan Withanage
  • Start date Start date
T

Thushan Withanage

Guest
i want to add all the data grid view records to a sql server database table from a button click.

there are 4 columns in the data grid view.

i have

class Database
{
private SqlConnection con;
private SqlCommand cmd;
private SqlDataAdapter da;
private SqlDataReader dr;

public Database()
{
con = new SqlConnection("Data Source=DESKTOP-GSJITB6\\MICROSOFT;Initial Catalog=NIBM;Integrated Security=True");
}

public void openConnection()
{
con.Open();
}
public void closeConnection()
{
con.Close();
}
public int save_update_delete(string a)
{
openConnection();
cmd = new SqlCommand(a, con);
int i = cmd.ExecuteNonQuery();
closeConnection();
return i;
}
}


used a separate class for the database connection.

i look forward to do the process by a sql injection.

Continue reading...
 
Back
Top