Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  View Answers    Answer this question    Ask a question  
 

Mistery1
Aug 4, 2009, 12:31 AM
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

shatrughna
Nov 20, 2009, 02:52 AM
Please try using sqldatasource and giving parameter value with ref. Control, cookies method you will able to insert records