NEWS & UPDATES >> BCA BCSP064 Synopsis & Project Work Started for DEC 2017, IGNOU MCA MCSP060 Synopsis Work Started for DEC 2017, CONTACT 4 IGNOU Mini Project

IGNOU BCA MCA Students - VIVA Question Answer for .NET Part III

IGNOU BCA MCA Students - VIVA Question Answer for .NET 

.NET Selected Question Answer - PART III

15. Which are Access Modifiers available in C#?
All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies.

You can use the following access modifiers to specify the accessibility of a type or member when you declare it:
public: The type or member can be accessed by any other code in the same assembly or another assembly that references it.
private: The type or member can be accessed only by code in the same class or struct.
protected: The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.
internal: The type or member can be accessed by any code in the same assembly, but not from another assembly.

16. Data Types in C#?
bool, byte , char, decimal , double, float, int, long, sbyte , short, uint, ulong, ushort.

More question coming soon.. we are updating our list of ques and answer... :)
keep wait and watch for few days.

17. Database connection with sql server and asp.net c#
Using ASP.NET 4 C# AND SQL server,
I have a connection string in web.config to myDatabase named "myCS". I have a database named myDB. I have a table named myTable with a primary key named myPK
What are the NECESSARY lines of code behind (minimal code) to create a SQL connection, then select from myTable where myPK=="simpleText"
it will probably include:
sqlconnection conn = new sqlconnection(??? myCS)
string SQLcommand = select * from myDB.myTable where myPK==myTestString;
sqlCommand command = new SqlCommand(SQL,conn);

conn.Open();

booleanFlag = ????

conn.Close();
conn.Dispose();
then
If ( theAnswer  != NULL )  // or (if flag)
{
Response.Redirect("Page1.aspx");
}
else
{
Response.Redirect("Page2.aspx");
}



DB Connection code just write if they ask
using (SqlConnection con = new SqlConnection("SomeConnectionString"))
{
  var cmd = new SqlCommand("select from myTable where myPK==N'"+ simpleText+ "'",con);
  cmd.Connection.Open();
  var sqlReader = cmd.ExecuteReader();
  while(sqlReader.Read())
  {
    //Fill some data like : string result = sqlReader("SomeFieldName");
  }
  sqlReader.Close();
  cmd.Connection.Close();
  cmd.Dispose();
}

No comments:

Post a Comment