<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0"><id>tag:blogger.com,1999:blog-4431829551095129349</id><updated>2024-09-12T23:19:30.170-07:00</updated><category term="Connection string"/><category term="Insert Command"/><category term="SQL 2005"/><category term="VB.Net"/><category term="programming practice"/><title type="text">Mikel Blog</title><subtitle type="html">all about my activity.</subtitle><link href="http://mike12chel.blogspot.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default" rel="self" type="application/atom+xml"/><link href="http://mike12chel.blogspot.com/" rel="alternate" type="text/html"/><link href="http://pubsubhubbub.appspot.com/" rel="hub"/><author><name>Michael</name><uri>http://www.blogger.com/profile/06923196231078632228</uri><email>noreply@blogger.com</email><gd:image height="16" rel="http://schemas.google.com/g/2005#thumbnail" src="https://img1.blogblog.com/img/b16-rounded.gif" width="16"/></author><generator uri="http://www.blogger.com" version="7.00">Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><xhtml:meta content="noindex" name="robots" xmlns:xhtml="http://www.w3.org/1999/xhtml"/><entry><id>tag:blogger.com,1999:blog-4431829551095129349.post-3489279071266611396</id><published>2008-05-04T17:32:00.000-07:00</published><updated>2008-05-04T17:37:48.553-07:00</updated><title type="text">CODE</title><content type="html">&lt;p&gt;-----------------Create table&lt;/p&gt;&lt;p&gt;--create table info-- (-- id int,-- fname varchar(50),-- lname varchar(50),-- phone varchar(50),-- address varchar(50),-- city varchar(50),-- state varchar(50),-- zip varchar(50),--constraint info_pk primary key (id));&lt;br /&gt;--create table Department-- (Dep_Id varchar(50),-- Dep_name varchar(50),--Constraint Department_PK primary key (Dep_Id));&lt;br /&gt;--create table Course-- (Course_Id varchar(50),-- Course_No varchar(50),-- Descrip Varchar(50),-- Dep_Id Varchar(50),--Constraint Course_PK primary key(Course_Id),--Constraint Course_FK foreign key (Dep_Id) references Department(Dep_Id));&lt;br /&gt;&lt;br /&gt;----------Insert data from other database&lt;/p&gt;&lt;p&gt;--use pracC--go--insert into info(fname,lname,phone,address,city,state,zip) --(--select au_fname,au_lname,phone,address,city,state,zip--from pubs.dbo.authors--)&lt;br /&gt;&lt;br /&gt;------------Create procedure&lt;br /&gt;--CREATE PROCEDURE addinfo-- @id varchar(50),-- @lname varchar(50),-- @fname varchar(50),-- @phone varchar(50),-- @add varchar(50),-- @city varchar(50),-- @state varchar(50),-- @zip varchar(50)-- --AS-- if not exists(select * from info where id = @id)-- -- begin -- insert into info-- (-- lname,-- fname,-- phone,-- address,-- city,-- state,-- zip-- )-- values-- (-- @lname,-- @fname,-- @phone,-- @add,-- @city,-- @state,-- @zip-- )-- -- end--else-- begin-- update info -- set -- lname = @lname,-- &lt;a href="mailto:fname=@fname"&gt;fname=@fname&lt;/a&gt;,-- phone = @phone,-- address = @add,-- &lt;a href="mailto:city=@city"&gt;city=@city&lt;/a&gt;,-- state = @state,-- zip = @zip-- where id like @id-- -- end&lt;br /&gt;&lt;br /&gt;--create procedure exescalar&lt;/p&gt;&lt;p&gt;-- @id varchar(50)--as--begin-- select lname from info where id like @id--end&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;---ClsFunction----------&lt;/p&gt;&lt;p&gt;Imports System.WindowsImports System.Text.RegularExpressions&lt;br /&gt;Public Class ClsFunction Inherits ClsConnection&lt;br /&gt;Sub listview(ByVal red As SqlClient.SqlDataReader, ByVal lv As ListView) lv.Items.Clear() While red.Read Dim i As Integer = 1 Dim lvi As ListViewItem = New ListViewItem(red(0).ToString()) While i &lt;= red.FieldCount - 1 lvi.SubItems.Add(red(i).ToString()) i = i + 1 End While lv.Items.Add(lvi) End While If lv.Items.Count &gt; 0 Then lv.Items(0).Selected = True End If End Sub&lt;br /&gt;Function reader(ByVal str As String) Return sqldatareader(str) End Function&lt;br /&gt;Sub fillcombo(ByVal cbx As ComboBox, ByVal red As SqlClient.SqlDataReader, ByVal column As String) While red.Read cbx.Items.Add(red(column).ToString()) End While End Sub Sub clearfields(ByVal cnt As Control) For Each c As Control In cnt.Controls If TypeOf c Is TextBox Then c.Text = "" End If 'If TypeOf c Is ComboBox Then ' c.Text = -1 'End If Next End Sub&lt;br /&gt;Sub validate(ByVal txtphone As TextBox) Dim valid As Boolean = True If Regex.Match(txtphone.Text, "^([a-zA-Z]+[a-zA-Z]+\\s[a-zA-Z]+)*$").Success Then MessageBox.Show("Please enter a valid last name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error) txtphone.Focus() valid = False Return End If 'bool valid = true;&lt;br /&gt;' If (!Regex.Match(txtFname.Text, "^[A-Za-z]+$").Success) Then ' { ' valid = false; ' MessageBox.Show("Please enter a valid first name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtFname.Focus(); ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtLname.Text, "^([a-zA-Z]+[a-zA-Z]+\\s[a-zA-Z]+)*$").Success) Then ' { ' MessageBox.Show("Please enter a valid last name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtLname.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtAdres.Text, "^([0-9]+\\s+([a-zA-Z]+[a-zA-Z]+\\s[a-zA-z]+))*$").Success) Then ' { ' MessageBox.Show("Please enter a valid address", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtAdres.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtSurb.Text, "^([a-zA-Z]+[a-zA-Z]+\\s[a-zA-Z]+)*$").Success) Then ' { ' MessageBox.Show("Please enter a valid suburb", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtSurb.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtPcode.Text, "^([0-9]+)$").Success) Then ' { ' MessageBox.Show("Please enter a valid post code", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); ' txtSurb.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtState.Text, "^([a-zA-Z]+[a-zA-Z]+\\s[a-zA-Z]+)*$").Success) Then ' { ' MessageBox.Show("Please enter a valid state", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtState.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtCountry.Text, "^([a-zA-Z]+[a-zA-Z]+\\s[a-zA-Z]+)*$").Success) Then ' { ' MessageBox.Show("Please enter a valid country", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtCountry.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtHometel.Text, "^([0-9]+[-().\\s]+)*$").Success) Then ' { ' MessageBox.Show("Please enter a valid phone number", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtHometel.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtOfficetel.Text, "^([0-9]+[-().\\s]+)*$").Success) Then ' { ' MessageBox.Show("Please enter a valid phone number", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtOfficetel.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtMob.Text, "^([0-9]+[-().\\s]+)*$").Success) Then ' { ' MessageBox.Show("Please enter a valid phone number", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtMob.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;' If (!Regex.Match(txtMail.Text, "^(([\\w-]+)@([\\w-]+\\.)+[A-Za-z]{2,3})*$").Success) Then ' { ' MessageBox.Show("Please enter a valid email address name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); ' txtMail.Focus(); ' valid = false; ' return; ' }&lt;br /&gt;End Sub&lt;br /&gt;Public Function number(ByVal Key As String) As Boolean If (Key &gt;= 48 And Key &lt;= 57) Or Key = 8 Or Key = 46 Or Key = 32 Then number = False Else number = True End If End Function Public Function character(ByVal Key As String) As Boolean If (Key &gt;= 48 And Key &lt;= 57) Then character = True Else character = False End If End FunctionEnd Class &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;-------ClsConnection------------&lt;br /&gt;Public Class ClsConnection Public con As New SqlClient.SqlConnection Sub connection() con = New SqlClient.SqlConnection("Data Source=MIKEL;Initial Catalog=pracC;Integrated Security=True") ' con = New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=practice;Integrated Security=True")&lt;br /&gt;End Sub&lt;br /&gt;Function sqldatareader(ByVal str As String) Try connection() Dim cm As New SqlClient.SqlCommand(str, con) Dim red As SqlClient.SqlDataReader con.Open() red = cm.ExecuteReader() Return red Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.Message, "Error") End Try End Function&lt;br /&gt;Sub execommand(ByVal str As String) Try connection() Dim cm As New SqlClient.SqlCommand(Str, con) con.Open() cm.ExecuteNonQuery() Finally If con.State = ConnectionState.Open Then con.Close() End If End Try&lt;br /&gt;End SubEnd Class&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;----ClsProcedure------&lt;br /&gt;Imports System.WindowsPublic Class ClsProcedure Inherits ClsConnection Public selectinfo As String Sub insertinfo(ByVal tfname As String, ByVal tlname As String, ByVal tphone As String, ByVal taddress As String, ByVal tcity As String, ByVal tstate As String, ByVal tzip As String, ByVal str As String) Try If str = "" Then execommand("insert into info values('" &amp;amp; tfname &amp;amp; "','" &amp;amp; tlname &amp;amp; "','" &amp;amp; tphone &amp;amp; "','" &amp;amp; taddress &amp;amp; "','" &amp;amp; tcity &amp;amp; "', '" &amp;amp; tstate &amp;amp; "','" &amp;amp; tzip &amp;amp; "')") MessageBox.Show("saved!!!") Else execommand("update info set lname = '" &amp;amp; tlname &amp;amp; "', fname = '" &amp;amp; tfname &amp;amp; "', phone = '" &amp;amp; tphone &amp;amp; "', address='" &amp;amp; taddress &amp;amp; "', state = '" &amp;amp; tstate &amp;amp; "', city = '" &amp;amp; tcity &amp;amp; "', zip = '" &amp;amp; tzip &amp;amp; "' where id like '" &amp;amp; str &amp;amp; "'") MessageBox.Show("Updated!!!") End If Catch ex As Exception MessageBox.Show(ex.Message, "error") End Try End Sub Sub deleteinfo(ByVal id As String) Try execommand("delete from info where id like '" &amp;amp; id &amp;amp; "'") MessageBox.Show("deleted!!!") Catch ex As Exception MessageBox.Show(ex.Message, "error") End Try End Sub Sub selectid(ByVal str As String) If str = "" Then selectinfo = "select * from info order by lname" Else selectinfo = "select * from info where id like '" &amp;amp; str &amp;amp; "'" End If End Sub&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;-----FORM CODE----------&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Public Class Form1 Dim func As New ClsFunction Dim pro As New ClsProcedure Dim red As SqlClient.SqlDataReader Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load loads() Timer1.Start() End Sub&lt;br /&gt;Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Me.ToolStripStatusLabel1.Text = "Date: " + Date.Today &amp;amp; vbCrLf &amp;amp; " Time: " + TimeOfDay End Sub&lt;br /&gt;Sub loads() pro.selectid("") red = func.reader(pro.selectinfo) func.listview(red, Me.ListView1)&lt;br /&gt;red = func.reader(pro.selectinfo) func.fillcombo(Me.ComboBox1, red, "lname") End Sub&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Private Sub ButSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButSave.Click If MessageBox.Show("Add...?", "add", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.OK Then pro.insertinfo(Me.TextFirstName.Text, Me.TextLastName.Text, Me.TextPhone.Text, Me.TextAddress.Text, Me.TextCity.Text, Me.TextState.Text, Me.TextZip.Text, Me.TextBox8.Text) ButClear.PerformClick() loads() End If&lt;br /&gt;End Sub&lt;br /&gt;Private Sub Butdel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Butdel.Click pro.deleteinfo(Me.ListView1.SelectedItems.Item(0).Text) loads() End Sub&lt;br /&gt;Private Sub ButClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButClear.Click func.clearfields(Me.GroupBox1) End Sub&lt;br /&gt;Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick pro.selectid(Me.ListView1.SelectedItems.Item(0).Text) red = func.reader(pro.selectinfo) While red.Read Me.TextBox8.Text = red("id").ToString() Me.TextFirstName.Text = red("fname").ToString() Me.TextLastName.Text = red("lname").ToString() Me.TextAddress.Text = red("address").ToString() Me.TextCity.Text = red("city").ToString() Me.TextPhone.Text = red("phone").ToString() Me.TextState.Text = red("state").ToString() Me.TextZip.Text = red("zip").ToString() End While End Sub&lt;br /&gt;Private Sub TextPhone_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextPhone.KeyPress e.Handled = func.number(Asc(e.KeyChar)) End Sub&lt;br /&gt;Private Sub TextLastName_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextLastName.KeyPress e.Handled = func.character(Asc(e.KeyChar)) End SubEnd Class&lt;br /&gt;&lt;/p&gt;&lt;p&gt;----Select statemnt for login---&lt;br /&gt;Select FName from user_t where UserName like '" &amp;amp; Me.TextBox1.Text &amp;amp; "' and Pass like '" &amp;amp; Me.TextBox2.Text &amp;amp; "' and UserType like '" &amp;amp; Me.ComboBox1.Text &amp;amp; "' &lt;/p&gt;</content><link href="http://mike12chel.blogspot.com/feeds/3489279071266611396/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/4431829551095129349/3489279071266611396" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/3489279071266611396" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/3489279071266611396" rel="self" type="application/atom+xml"/><link href="http://mike12chel.blogspot.com/2008/05/code.html" rel="alternate" title="CODE" type="text/html"/><author><name>Michael</name><uri>http://www.blogger.com/profile/06923196231078632228</uri><email>noreply@blogger.com</email><gd:image height="16" rel="http://schemas.google.com/g/2005#thumbnail" src="https://img1.blogblog.com/img/b16-rounded.gif" width="16"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4431829551095129349.post-893528125344382648</id><published>2008-03-05T05:16:00.000-08:00</published><updated>2008-03-07T06:00:04.513-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Connection string"/><category scheme="http://www.blogger.com/atom/ns#" term="Insert Command"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL 2005"/><category scheme="http://www.blogger.com/atom/ns#" term="VB.Net"/><title type="text">The insert command - VB.Net code and save to SQL Server 2005</title><content type="html">&lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;A simple code on how to connect sql 2005 from VB.Net via SQL &lt;a href="http://www.connectionstrings.com/"&gt;connection string&lt;/a&gt;, and the use of &lt;b&gt;ExecuteNonQuery()&lt;/b&gt; method to execute the command and the try and catch to catch errors during runtime.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(204, 0, 0);"&gt;Example information:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;SQL data:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-indent: 0.5in;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Database name: &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;user&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-indent: 0.5in;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Table name: &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;user_t&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-indent: 0.5in;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Columns: &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;user_id,lname,fname,username,password,usertype&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-indent: 0.5in;"&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Controls:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;textboxes:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt; textID = for Id&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-indent: 0.5in;"&gt;&lt;span style="font-size: 10pt;"&gt;textlname = for last name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-indent: 0.5in;"&gt;&lt;span style="font-size: 10pt;"&gt;textfname = for first name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 5pt 0in 0.0001pt 0.5in;"&gt;&lt;span style="font-size: 10pt;"&gt;textusername = for user name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt; text-indent: 0.5in;"&gt;&lt;span style="font-size: 10pt;"&gt;textpassword = for password&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;combobox:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt; comboUsertype = for user type&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt; color: rgb(204, 0, 0);"&gt;Code:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Dim &lt;b&gt;con&lt;/b&gt; As New SqlClient.SqlConnection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Dim &lt;b&gt;strCon&lt;/b&gt; as string = "Data Source=MIKEL\SQLEXPRESS;Initial Catalog=user_t;Integrated Security=True"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Dim &lt;b&gt;strCommand&lt;/b&gt; as string&lt;b&gt; = “&lt;/b&gt;Insert into user_t (user_id, lname, fname, username, password, usertype) values (‘”&amp;amp; me.textID.text &amp;amp;”’,‘” &amp;amp; me.textlname.text &amp;amp;”’, ‘” &amp;amp;me.fname.text &amp;amp;”’, ‘”&amp;amp;me.textusername.text &amp;amp;”‘,‘”&amp;amp; me.textpassword.text &amp;amp;”’,‘”&amp;amp;me.comboUsertype.text &amp;amp;”’)”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Sub insert()&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;con.ConnectionString = strCon&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Dim cm As New SqlClient.SqlCommand(strCommand, con)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;con.Open()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;cm.ExecuteNonQuery()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;MsgBox("Succesfully saved…")&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Catch ex As Exception&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;MessageBox.Show(ex.Message, "Error")&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Finally&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;If con.State = ConnectionState.Open Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;con.Close()&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;End If&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;End Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;End sub&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt;"&gt;&lt;br /&gt; &lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt; &lt;!--[endif]--&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</content><link href="http://mike12chel.blogspot.com/feeds/893528125344382648/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/4431829551095129349/893528125344382648" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/893528125344382648" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/893528125344382648" rel="self" type="application/atom+xml"/><link href="http://mike12chel.blogspot.com/2008/03/insert-command-from-vbnet-to-sql-2005.html" rel="alternate" title="The insert command - VB.Net code and save to SQL Server 2005" type="text/html"/><author><name>Michael</name><uri>http://www.blogger.com/profile/06923196231078632228</uri><email>noreply@blogger.com</email><gd:image height="16" rel="http://schemas.google.com/g/2005#thumbnail" src="https://img1.blogblog.com/img/b16-rounded.gif" width="16"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4431829551095129349.post-8111580802483520856</id><published>2008-03-04T05:26:00.000-08:00</published><updated>2008-03-05T01:46:46.926-08:00</updated><title type="text">Basic insert, delete, update command in SQL </title><content type="html">&lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Hi... these are just a basic insert, delete, and update command in database SQL (200, 2005) .&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Example data&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Database name: &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;user&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Table name: &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;user_t&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Columns: &lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;user_id,lname,fname,username,password,usertype&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;____________________________________________________________________________&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Insert command&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Insert into user_t (user_id, lname, fname, username, password, usertype) values (@parameter1, @parameter2, @parameter3, @parameter4, @parameter5, @parameter6)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;It means, @parameter1 is a value that points to user_id, @parameter2 points to lname and so on…..&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Update command&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Update user_t set lname = @parameter1, fname = @parameter2, username = @parameter3, password = @parameter4, usertype = @parameter5 where user_id like @parameter6&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;b&gt;&lt;span style="font-size: 10pt;"&gt;Delete command&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p style="margin-bottom: 0.0001pt;"&gt;&lt;span style="font-size: 10pt;"&gt;Delete from user_t where user_id like @parameter1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt;"&gt;To download SQL server 2005 express edition and .Net framework 2.0 click &lt;a href="http://msdn2.microsoft.com/en-us/express/bb410792.aspx"&gt;here&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt;"&gt;To download Visual Studio 2005 click &lt;a href="http://msdn2.microsoft.com/en-us/express/aa975050.aspx"&gt;here&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt;"&gt;&lt;br /&gt; &lt;!--[if !supportLineBreakNewLine]--&gt;&lt;br /&gt; &lt;!--[endif]--&gt;&lt;u1:p&gt;&lt;/u1:p&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;</content><link href="http://mike12chel.blogspot.com/feeds/8111580802483520856/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/4431829551095129349/8111580802483520856" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/8111580802483520856" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/8111580802483520856" rel="self" type="application/atom+xml"/><link href="http://mike12chel.blogspot.com/2008/03/basic-insert-delete-update-command-in.html" rel="alternate" title="Basic insert, delete, update command in SQL &lt;a href=&quot;http://technorati.com/claim/jf4skas7u&quot; rel=&quot;me&quot;&gt;&lt;/a&gt;" type="text/html"/><author><name>Michael</name><uri>http://www.blogger.com/profile/06923196231078632228</uri><email>noreply@blogger.com</email><gd:image height="16" rel="http://schemas.google.com/g/2005#thumbnail" src="https://img1.blogblog.com/img/b16-rounded.gif" width="16"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4431829551095129349.post-651939034170964206</id><published>2008-02-27T13:46:00.001-08:00</published><updated>2008-03-07T05:55:06.645-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="programming practice"/><title type="text">My start in .net programming</title><content type="html">&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt;"&gt;I am practicing .Net programming in short I am a beginner. Its quiet difficult for me without any helpful resources and friends to ask for, I know, to be a good programmer is not just a drag and drop like what I am doing in Visual studio. It takes time, effort and patience. On the start of my practice, I always get mystified and my mind is fully loaded of questions. I have no outline if where I should start and where to end, I am just applying ideas pop out in my mind.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt;"&gt;I want to master .Net Programming and I am using Visual Studio 2005 as my IDE. For easy and for prompt learning, I joined online tutorials, forum and I have downloaded free e-books and videos. By the way, somebody knows where can I download &lt;b&gt;free VB.Net tutorial videos&lt;/b&gt;? :-) I been trying to search in the internet but all are for sale. I have only downloaded the ASP.net free tutorials videos from &lt;a href="http://www.asp.net/"&gt;ASP.net&lt;/a&gt; website.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;&lt;u2:p&gt;&lt;/u2:p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt;"&gt;For now, VB.Net is my PL and I am working with forms and controls and bind them with data from the database. I am using SQL Server 2005 as my backend database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;&lt;u2:p&gt;&lt;/u2:p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-size: 10pt;"&gt;I have only three questions “what if”, “how” and “where to find the solution”. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;u1:p&gt;&lt;/u1:p&gt;&lt;u2:p&gt;&lt;/u2:p&gt;  &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt;"&gt;Check out for my next post: my practice status and discoveries&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</content><link href="http://mike12chel.blogspot.com/feeds/651939034170964206/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/4431829551095129349/651939034170964206" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/651939034170964206" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/651939034170964206" rel="self" type="application/atom+xml"/><link href="http://mike12chel.blogspot.com/2008/02/my-start-in-net-programming.html" rel="alternate" title="My start in .net programming" type="text/html"/><author><name>Michael</name><uri>http://www.blogger.com/profile/06923196231078632228</uri><email>noreply@blogger.com</email><gd:image height="16" rel="http://schemas.google.com/g/2005#thumbnail" src="https://img1.blogblog.com/img/b16-rounded.gif" width="16"/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4431829551095129349.post-2540607418208460070</id><published>2008-02-07T21:44:00.000-08:00</published><updated>2008-02-07T21:59:40.933-08:00</updated><title type="text">My first Post</title><content type="html">&lt;script type="text/javascript"&gt;&lt;!--&lt;br /&gt;google_ad_client = "pub-9123994678886484";&lt;br /&gt;/* 728x90, created 2/7/08 */&lt;br /&gt;google_ad_slot = "2765100503";&lt;br /&gt;google_ad_width = 728;&lt;br /&gt;google_ad_height = 90;&lt;br /&gt;//--&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&lt;br /&gt;src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;this would be my first post and this would be my personal blog.&lt;br /&gt;&lt;br /&gt;Hello</content><link href="http://mike12chel.blogspot.com/feeds/2540607418208460070/comments/default" rel="replies" title="Post Comments" type="application/atom+xml"/><link href="http://www.blogger.com/comment/fullpage/post/4431829551095129349/2540607418208460070" rel="replies" title="0 Comments" type="text/html"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/2540607418208460070" rel="edit" type="application/atom+xml"/><link href="http://www.blogger.com/feeds/4431829551095129349/posts/default/2540607418208460070" rel="self" type="application/atom+xml"/><link href="http://mike12chel.blogspot.com/2008/02/my-first-post.html" rel="alternate" title="My first Post" type="text/html"/><author><name>Michael</name><uri>http://www.blogger.com/profile/06923196231078632228</uri><email>noreply@blogger.com</email><gd:image height="16" rel="http://schemas.google.com/g/2005#thumbnail" src="https://img1.blogblog.com/img/b16-rounded.gif" width="16"/></author><thr:total>0</thr:total></entry></feed>