guys... please help me to save, edit and delete files in the data grid...
can you give me the codes so i can do it...
i badly need it for my system...
you'll need SQL queries to achieve these things:
Here is the step-by-step procedure to INSERT a record into an SQL database:
1. Create your VB.NET project.
2. Include the following namespaces.
Imports System.Data 'Required for SQL Imports System.Data.SqlClient 'Required for SQL
The System.Data namespace provides access to classes that represent the ADO.NET architecture while the System.Data.SqlClient namespace is the .NET Framework Data Provider for SQL Server.
3. Declare and instantiate your SQLConnection object and Command object as shown below
Dim con As New SqlConnection Dim cmd As New SqlCommand
4. Pass the SQL connection string to ConnectionString property of your SQLConnection object.
con.ConnectionString = "Data Source=example;Initial Catalog=example;Persist Security Info=True;User ID=admin;Password=admin"
5. Use the Open Method to connect to SQL Server.
6. Set the connection of the command object.
cmd.Connection = con
7. Pass the INSERT SQL statement to the command object commandtext as shown below
cmd.CommandText = "INSERT INTO ExampleTable (field1, [field2, ... ]) VALUES (value1, [value2, ...])"
8. Use the ExecuteNonQuery() method to run the INSERT SQL statement that has no return value.
If you want a return value use ExecuteScalar() instead.
A good example of ExecuteScalar is to get the Identity column after inserting record(ExecuteScalar returns the first column of the first row from the result).
Full sample source code of inserting record to SQL Database:
Dim con As New SqlConnection 'Define variable con as a new SQL Server Connection Dim cmd As New SqlCommand 'Define variable cmd as a new SQL Server Command Try 'Used for Error Logging - Try/Catch con.ConnectionString = "Data Source=examplesource;Initial Catalog=Example;Persist Security Info=True;User ID=admin;Password=admin" 'Sets the properties of the connection string con.Open() 'Invokes the server connection to Open cmd.Connection = con 'The Connection Used for the SQL Command cmd.CommandText = "INSERT INTO ExampleTable([field1], [field2]) VALUES([Value1], [Value2])" 'Sets The Command Text To An Insert Query cmd.ExecuteNonQuery() Catch ex As Exception ' If there's an error, catch it! MsgBox("Error while inserting record on table..." & ex.Message, "Insert Records") 'Displays a Message Box popup to the user notifying them of an error (if any) Finally con.Close() 'Close the SQL connection (Well you wouldn't leave your car door open when you get out of it would you?) End Try
Edited 6 Years Ago by JJCollins: n/a
I am developing a simple job card creator application with VB.net 2012, using Access 2010 as database.
The code I have generated to write data from a datagridview to the database table is successfully saving the data, but with an error "Parameter @name has no default value". The ...
write a C++ program which take inputs from the user/keyboard and calculate his ZAKAT.
get the input from user may include
-Amount invested in business
-Amount given to other business partners as loan
-Amount payable to others
I made a prime number finder, it finds the nearest prime that is above and below any integer (Does not work that well with giant numbers.)
Made this in cpp.sh
Why would I need the x=y+1-1;?
x=y; just doesnt seem to work
Why is this?
And I know my coding ...