| After creating it, you can copy the SQL code too. Essential steps:
|
15 May 2009
Video: Microsoft Visual Studio 2008 - How to create DELETE SQL statement visually
08 May 2009
VB.Net code: ADO.Net – Insert a record to a table
'Insert a record into customer table
'note: CustomerID is nchar(5). Primary Key
Dim sql As String = "INSERT INTO Customers " & _
"(CustomerID, CompanyName, ContactName, ContactTitle) " & _
"VALUES ('" & strCustomerID & "','" & _
strCompanyName & "','" & _
strContactName & "','" & _
strContactTitle & "')"
Dim connStr As String = "server=localhost; uid=sa; password=myPassWord; database=Northwind"
Dim conn As SqlConnection = New SqlConnection(connStr)
Dim comm As SqlCommand = New SqlCommand(sql, conn)
conn.Open()
Dim intRowsAdded As Integer
intRowsAdded = comm.ExecuteNonQuery()
'You can use the ExecuteNonQuery to update/delete record too.
conn.Close()
conn = Nothing
comm = Nothing
You might need to modify the some VB code. Example:
server=.\sqlexpress; uid=sa; pasword=wna05;
- for accessing MS SQL Express in the localhost
or, server=myComputerName\sqlexpress -depends on your notebook configuration
07 May 2009
VB.Net code: How to pass a public variable intIndex between windows forms
Step 1: Delclare the variable intIndex in Form1 as follows.
Public Class Form1
Inherits System.Windows.Forms.Form
Public Shared intIndex As Integer
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
intIndex = TextBox1.Text
Dim myForm As New Form2
myForm.Show()
End Sub
Step 2: How the form2 access the intIndex variable.
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Text = Form1.intIndex
End Sub
Other note:
Me.close() - to close the form.