Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one problem in which I can enter some data to the database. How can I code this things? I used Insert and update query. The values types are double,integer and also string.
Posted
Updated 7-Nov-10 4:56am
v2
Comments
Rajesh Anuhya 8-Nov-10 3:57am    
Your Question is not Clear.., and it's seems you are not put any Effort

What you tried??,

Here am Providing the sample code for executing insert/update commands
Imports System.Data.OleDb
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim connetionString As String
        Dim cnn As OleDbConnection
        Dim cmd As OleDbCommand
        Dim sql As String

        connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;"
        sql = "Your SQL Statement Here"

        cnn = New OleDbConnection(connetionString)
        Try
            cnn.Open()
            cmd = New OleDbCommand(sql, cnn)
            cmd.ExecuteNonQuery()
            cmd.Dispose()
            cnn.Close()
            MsgBox(" ExecuteNonQuery in OleDbConnection executed !!")
        Catch ex As Exception
            MsgBox("Can not open connection ! ")
        End Try
    End Sub

End Class
 
Share this answer
 
Comments
Simon_Whale 8-Nov-10 4:03am    
nice piece of code, but it doesn't show the OP how to pass a NULL Value
If you need to pass a null value to a database, use DBNull.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900