Open Means Open Means

This is code to insert Grid details in vb.net you can use this function in common class.

you also need to declare required variable globally.

public Boolean InsertGridDetails(ref DataTable dt, string TableName, String PkValue, string PkName,SqlTransaction SqlTrans,SqlConnection Cn)
    {
        try
        {
            string query = "";
            query = "select * from " + TableName + " where " + PkName + " = '" + PkValue + "'";
            cmd = new SqlCommand(query, Cn);
            cmd.Transaction = SqlTrans;
            DA = new SqlDataAdapter(cmd);
            SqlCommandBuilder GridDetail = new SqlCommandBuilder(DA);
            DA.Update(dt);
            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
                     cmd.Dispose();
            DA.Dispose();
        }
    }

No comments

Login to post a comment

Show
  • Create an account
  • Forgot your username?
  • Forgot your password?
  • About Us
  • Faqs
  • Contact Us
  • Disclaimer
  • Terms & Conditions