Ask Experts Questions for FREE Help !
Ask
    Mistery1's Avatar
    Mistery1 Posts: 39, Reputation: 1
    Junior Member
     
    #1

    Jul 30, 2009, 07:51 AM
    Inserting data into a database using asp.net(visual Basic)
    Hi there,


    Protected Sub ButtonSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonSubmit.Click


    Dim cn As New OleDbConnection
    Dim str As String
    Dim cmd As New OleDbCommand

    cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Documents and Settings\Mistery1\Desktop\Emp.mdb;")
    cn.Open()


    Str = "INSERT INTO EmpNames(EmpNo, Ename, Department) VALUES(" & CInt(TextBoxEmpNo.Text) & ",'" & TextBoxEname.Text.Replace("'", "''") & "','" & TextBoxDepartment.Text.Replace("'", "''") & "')"

    cmd = New OleDbCommand(Str, cn)
    str = cmd.ExecuteNonQuery

    cn.Close()

    End sub



    I am trying to create a website using ASP.net 2.0 and VB(not c#). The code above works perfectly when used as a windows application but not as a web application.

    Please could someone tell me where I'm going wrong. I don't get any errors, just NO entry in the database. I have googled but to no avail.

    Please help

Check out some similar questions!

Inserting Data To Access From DataGridView [ 3 Answers ]

Hi, I'm trying to build an application where the user could enter data in a datagridview and the it should be inserted into an Access Database (or to SQL Server which ever you will advise me to use) I know who to create a DataSet, I tried creating a new DataTable in the dataset and bind that...

Inserting data from multiple forms [ 1 Answers ]

How to insert data in the same row of access database from multiple form? I have three forms and I can insert data to the access database.. but when I view the Database in gridview.. I found that at serial number 1 my form1 data show.. but form2 data are shown in serial number 2 and form3 data...

Inserting an aprostrophe into an Ms access database [ 2 Answers ]

Hi there, I have the ffg code so far, which inserts info into the database. But how do I go about inserting/ writing code to insert a surname like O'Reily (take not of the aprostrophe) into the database. Imports System.Data.OleDb Public Class Form1 Public cn As OleDbConnection ...

Design a database application n Access or Visual Basic which can be used by a student [ 2 Answers ]

You have to design a simple application In Access and/or Visual Basic which can be used by a student joining a University to record details about himself, his course and his registration and fees paid for each year. Requirements: You should be able to add, update and delete details of...

A simple database system using visual basic [ 1 Answers ]

I don't know what I'm going to propose. I need some examples of beautiful and useful project proposals that I will propose for my project in principles of programming language. It will be in database,so I need the name of a system so that I can make a database and program it using visual basic. I...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.