Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Dot Net Framework Practical Slip 24 Answers

  Dot Net Framework


 Dot Net Framework

A) Write a program in C#.Net to create a function to check whether a number is prime or

not.

Answer :

namespace WinFormsApp26

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        public static String prime(int a)

        {

           Boolean isprime = true;

           int  b = a/2;

            for(int i = 2; i <= b; i++)

            {

                if(a % 2 == 0)

                {

                    isprime = false;

                    break;

                }

            }

            if (isprime)

            {

                return a + " is Prime Number";

            }

            else

            {

                return a + " is Not Prime Number";

            }

        }

        private void button1_Click(object sender, EventArgs e)

        {

            MessageBox.Show(prime(Convert.ToInt32(textBox1.Text)));

        }

    }

}

Output :

 

Write a program in C#.Net to create a function to check whether a number is prime or  not.

B) Write a VB.NET program to create Author table (aid, aname, book_ name). Insert the

records (Max 5). Delete a record of author who has written “VB.NET book” and

display remaining records on the data grid view. (Use MS Access to create db.)

Answer :

Imports System.Data.OleDb

Public Class Form1

    Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Saurabh\Desktop\New folder\Author.accdb")

    Dim adpt As New OleDbDataAdapter("Select * from Author", con)

    Dim cmd As New OleDbCommand

    Dim ds As New DataSet

    Public Function display()

        adpt.Fill(ds, "Author")

        DataGridView1.DataSource = ds

        DataGridView1.DataMember = "Author"

        Return ds

    End Function

 

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        display()

    End Sub

 

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        cmd.Connection = con

        cmd.CommandType = CommandType.Text

        cmd.CommandText = "insert into Author values(" & TextBox1.Text & ",'" & TextBox2.Text & "','" & TextBox3.Text & "')"

        con.Open()

        If cmd.ExecuteNonQuery() Then

            MessageBox.Show("Inserted Successfully...!")

        End If

        con.Close()

        ds.Clear()

        display()

    End Sub

 

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        cmd.Connection = con

        cmd.CommandType = CommandType.Text

        cmd.CommandText = "DELETE FROM Author WHERE book_name='" & TextBox3.Text & "'"

        con.Open()

        If cmd.ExecuteNonQuery() Then

            MessageBox.Show("Deleted Successfully...!")

        End If

        con.Close()

        ds.Clear()

        display()

    End Sub

End Class

Output :


Write a VB.NET program to create Author table (aid, aname, book_ name). Insert the  records (Max 5). Delete a record of author who has written “VB.NET book” and  display remaining records on the data grid view. (Use MS Access to create db.)

Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Dot Net Framework Practical Slip 24 Answers Savitribai Phule Pune University T.Y.B.B.A.(C.A.) Dot Net Framework Practical Slip 24 Answers Reviewed by technical_saurabh on May 02, 2022 Rating: 5

No comments:

Powered by Blogger.