Your technology certification is waiting. Enroll in Cloud Class ®
' Add this Imports to the top of the page
Dim myConnectionString As String = _
"Data Source=.\SQLEXPRESS;AttachDbFilename='C:\myDatabase.mdf';" & _
";Integrated Security=True;User Instance=True"
' Defines the T-SQL command
Dim SQL As String = "INSERT INTO myTable([username], [date]) VALUES (@username, @date);"
' Create a new connectio class
Using connection As New SqlConnection(myConnectionString)
' Creates the command that will do the T-SQL
Using command As New SqlCommand(SQL, connection)
' Add's the parameters that will be inserted
command.Parameters.Add("@username", SqlDbType.VarChar).Value = "jpaulino"
command.Parameters.Add("@date", SqlDbType.DateTime).Value = DateTime.Now
' Executes the command
Dim x As Integer = command.ExecuteNonQuery()
If x < 1 Then
MessageBox.Show("No records inserted.")
Open in new window
Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.