CSharp Use Sql Directly To Insert Data Into Database In Vb.Net – ADO.Net Database

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %><script language="VB" runat="server">  Sub Page_Load(Sender As Object, E As EventArgs)    Dim objConnection As OleDbConnection
    Dim objCmd        As OleDbCommand
    Dim strConnection As String
    Dim strSQL        As String
    strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                    "Data Source="+MapPath("EmployeeDatabase.mdb")
    ' Create and open the connection object
    objConnection = New OleDbConnection(strConnection)
    ' set the SQL string
    strSQL = "INSERT INTO Employee(FirstName,LastName)" & _
                      " VALUES ( 'Beth' , 'Hart' )"    ' Create the Command and set its properties
    objCmd = New OleDbCommand(strSQL, objConnection)
    ' execute the command
    objCmd.ExecuteNonQuery()    lblStatus.Text = "Command run"  End Sub</script><html>
    <h2>Using SQL directly</h2>
    <asp:Label id="lblStatus" runat="server"/>

Enjoyed this post? Share it!


Leave a comment

Your email address will not be published.