dynamic _FileName = Strings.Mid(FileName, 1, Strings.InStrRev(pFileName,My.Computer.FileSystem.GetFileInfo(pFileName).Extension));
Use dialogResult in C#.net
Click Event
DialogResult dr = MessageBox.Show("Do you want to delete a record", "Test", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes )
{
// DO Sommthig(Delete a record)
}
else if (dr == DialogResult.No)
{
//Do Something(Error message)
}
Labels:
C#.Net
different between Parse and Convert
Convert class makes it easier to convert between the all the base types.
One Difference:
string is null
thrown error when you call int.Parse()
return 0 value when you call Convert.ToInt32()
if you want to know the Difference between Int.Parse() and Convert.ToINT32(). please test the following code:
Output is same when you use your code.
One Difference:
string is null
thrown error when you call int.Parse()
return 0 value when you call Convert.ToInt32()
if you want to know the Difference between Int.Parse() and Convert.ToINT32(). please test the following code:
int a, b;
string s = null;
b = Convert.ToInt32(s);
MessageBox.Show(b.ToString());
a = int.Parse(s);
MessageBox.Show(a.ToString());
Labels:
Interview Question and Answer,
VB.Net
MDI Background Image Layout
How to set BackgroundImageLayout in MDI?
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center
Labels:
C#.Net
difference betweent Convert.ToDouble and Double.Parse
ConvertTo.Double returns 0 when nothing is passed, whereas Double. Parse
throws an exception.
throws an exception.
Hide & show a Column in Datagridview using C#.net
Hide a column in Datagridview:
Show a column in Datagridview:
dataGridView1.Columns["Column Name"].Visible = false;
Show a column in Datagridview:
dataGridView1.Columns["Column Name"].Visible = true;
Labels:
C#.Net
StringBuilder in Class file using C#.Net
Create a Class file in your project.
My class file name is Master.cs.In that class file , i create a Two Properties and One String Builder .
In my For , It contains 2 Test Box and One Command Button. I called a class(Master) when user clicks a Command button
My class file name is Master.cs.In that class file , i create a Two Properties and One String Builder .
public int TestId { get; set; }
public string TestName { get; set; }
public StringBuilder result = new StringBuilder();
Master mst = new Master();
mst.TestId = Convert.ToInt32(txtId.Text);
mst.TestName = txtName.Text;
mst.result.Append( "Id No:" + mst.TestId + " " + "Name" + " " + mst.TestName);
MessageBox.Show(mst.result.ToString())
Labels:
C#.Net
Store Procedure for Beginners
Database is a important thing in the Software Development. I think, without database, we can't do the Software .So it is a Primary one. So every Program should know the Database Concept, Structures and Usages.
Store Procedure (SP):
The following Points are the Store Procedures Definition and usages:
1. Group of T-SQL statements compiled into a single execution plan.
2. Store and Retrieve information from Database.
3. T-SQL task has executed within the Application
4. Increase Performance
5. Storing a code inside in the SQL -Server
Create a Store Procedure
1. Select Query
2. Insert Query
Store Procedure (SP):
The following Points are the Store Procedures Definition and usages:
1. Group of T-SQL statements compiled into a single execution plan.
2. Store and Retrieve information from Database.
3. T-SQL task has executed within the Application
4. Increase Performance
5. Storing a code inside in the SQL -Server
Create a Store Procedure
1. Select Query
Create Procedure SP_userlogin
As
Select username, password from tbl_Login
Run this Query.2. Insert Query
Create Procedure SP_Insertuserlogin
@userid varchar (20),
@username varchar (50),
@password varchar (50)
As
Insert into tbl_ Login (userid, username, password) values (@userid, @username,@ password)
3. Update Query
Create Procedure SP_Updateuserlogin
@userid varchar (20),
@username varchar (50),
@password varchar (50)
As
Update tbl_Login set username=@username, password=@password where userid=@userid
4. Delete Query
Create Procedure SP_Deleteuserlogin
@userid varchar (20),
As
Delete from tbl_Login where userid=@userid
Search the Store Procedure in the SQL SERVER
SP_HELPTEXT SP_Name
For Ex:
SP_Helptext SP_userlogin
Select the Line and Press F5.
You view the Store Procedure like this
Create Procedure SP_userlogin
As
Select username, password from tbl_Login
If you want to Modify in your store procedure:
Alter Procedure SP_userlogin
As
Select distinct username, password from tbl_Login
Labels:
Database
Screen Resolution Program in C#.net
Simply says, Display Resolution or Monitor Resolution. I give the demo for Screen Resolution. It's a very simple and easily understandable How to maximize a form without using Maximize Button?
Use this Code.
In the Namespace
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;
//Form Loading
private void Form1_Load(object sender, EventArgs e)
{
// To get Current Screen Resoltion
int tempwidth = Screen.PrimaryScreen.Bounds.Width;
int tempHeight = Screen.PrimaryScreen.Bounds.Height;
int tempX = Screen.PrimaryScreen.Bounds.X;
int tempY = Screen.PrimaryScreen.Bounds.Y;
this.Width = tempwidth;
this.Height = tempHeight-15;
this.Location = new Point(tempX, tempY);
dataGridView1.Width = tempwidth;
dataGridView1.Height = tempHeight;
int tempcol = tempwidth / 5;
dataGridView1.Columns[0].Width = tempcol;
dataGridView1.Columns[1].Width = tempcol;
dataGridView1.Columns[2].Width = tempcol;
dataGridView1.Columns[3].Width = tempcol;
dataGridView1.Columns[4].Width = tempcol;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
}
Labels:
C#.Net