If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > can some one help me pls

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-06-09, 03:29
NaveenRavi NaveenRavi is offline
Registered User
 
Join Date: Feb 2009
Posts: 1
can some one help me pls

ian using visual studio 2005 to gesign my asp pages and i have aa access database to hold few important information
the problem is iam not able to connect to it to upload new valuse

its like i have a forum from which i get the new entries from the customers and upload it to the data base
my code is like this


Imports System.Data.OleDb
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=MyDB.mdb;")
Dim da As New OleDbDataAdapter("select * from emp", cn)
Dim dt As New Data.DataTable
da.Fill(dt)
da.Dispose()
cn.Dispose()
Me.GridView1.DataSource = dt
Me.GridView1.DataBind()
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=MyDB.mdb;")
Dim cmd As New OleDbCommand
With cmd
.CommandText = "insert into emp (Empno,Ename,Sal,Deptno) values (" & Me.TextBox1.Text & ",'" & Me.TextBox2.Text & "'," & Me.TextBox3.Text & "," & Me.TextBox4.Text & ")"
.Connection = cn
.Connection.Open()
.ExecuteNonQuery()
.Connection.Close()
.Dispose()
End With
cn.Dispose()
'refresh the list
'btnList_Click(Nothing, Nothing)




End Sub
End Class

the button one is used to add the entered datas into the data base
and the second button to view the updated databse
Reply With Quote
  #2 (permalink)  
Old 02-06-09, 04:05
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Welcome to the forum

I'm going to move this post to the ASP section where you're more likely to get a targetted response.
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 02-09-09, 16:31
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
...so do you get any error messages?
Can you construct the command string for the insert command in a variable, then .Write that, finally pasting the results back here so we can see?
__________________
George
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 02-17-09, 10:54
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
Look in to "prepared statements". They will probably solve a number of your current headaches.
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #5 (permalink)  
Old 02-17-09, 12:42
powernicholas powernicholas is offline
Registered User
 
Join Date: Aug 2008
Posts: 12
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=MyDB.mdb;")

my experience is that DataSource=

needs to be followed by a path...either locally or url

i.e. c:\temp\MyDB.mdb
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On