Friday, October 10, 2008

VB Tutorials

Database connection with MSAcess Database and insert,update,delete,select commands in VB

Output is:



Source Code is:

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub Combo1_Click()
rs.Open "select * from punch where Card_id='" & Combo1.Text & "' ", con, adOpenDynamic, adLockBatchOptimistic
While rs.EOF = False
Text1.Text = rs(0)
Text2.Text = rs(1)

rs.MoveNext
Wend
rs.Close
End Sub

Private Sub Command1_Click()
rs.Open "select * from punch where Card_id='12'", con, adOpenDynamic, adLockBatchOptimistic
While rs.EOF = False
Text1.Text = rs(0)
Text2.Text = rs(1)
rs.MoveNext
Wend
rs.Close
End Sub

Private Sub Command2_Click()
con.Execute "insert into punch values('" & Text1.Text & "','" & Text2.Text & "')"
MsgBox "inserted"
End Sub

Private Sub Command3_Click()
con.Execute "update punch set User_Name='" & Text2.Text & "' where Card_id='" & Text1.Text & "'"
MsgBox "updated"

End Sub

Private Sub Command4_Click()
con.Execute "delete from punch where Card_id='" & Text1.Text & "'"
MsgBox "deleted"

End Sub

Private Sub Form_Load()
con.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & " data source=" & App.Path & "\pu.mdb"
con.Open
rs.Open "select Card_id from punch", con, adOpenDynamic, adLockBatchOptimistic
While rs.EOF = False
Combo1.AddItem rs(0)
rs.MoveNext
Wend
rs.Close

End Sub

Tuesday, July 29, 2008

AddItems

int HiddenValue;

protected void Button1_Click(object sender, EventArgs e)
{
HiddenValue = Convert.ToInt32(HiddenField1.Value.ToString());
ListBox1.Items.Add("Item " + HiddenValue.ToString());
Label4.Text = HiddenValue.ToString();
HiddenValue = HiddenValue + 1;
HiddenField1.Value = HiddenValue.ToString();
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox1.Text = ListBox1.SelectedItem.Text.ToString();
}

TextBox Control

protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = "You have clicked the button";
TextBox4.Text = "This is a multi line textbox. This is a multi line textbox. This is a multi line textbox. This is a multi line textbox. ";

TextBox3.Text = TextBox2.Text;
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox1.Text = "The Text is changed.";

}

Literal Control

protected void Button1_Click(object sender, EventArgs e)
{
Literal1.Text = "Welcome to ASP.NET 2.0";
}

Label Control

Source Code is:

protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Label Text changed";
Label1.BorderStyle = BorderStyle.Dotted;
Label1.BackColor = System.Drawing.Color.Aqua;
}
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Visible =!(Label1.Visible);
}

HiddenField Control

Html Code is:

asp:HiddenField ID="HiddenField1" runat="Server" Value="Welcome to ASP.NET 2.0"
Visible="False"

Source Code is:


protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = HiddenField1.Value;
}

File Upload Control

Source Code:

protected void Button1_Click(object sender, EventArgs e)
{
if( FileUpload1.HasFile)
{

FileUpload1.SaveAs("C:/projects/" + FileUpload1.FileName);
Label2.Text = "File Uploaded";
}
else
Label2.Text = "No uploaded file";

}

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...