HighDots Forums  

Converting ASP Data Connections to ASP.NET

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Converting ASP Data Connections to ASP.NET in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
CES
 
Posts: n/a

Default Converting ASP Data Connections to ASP.NET - 08-02-2004 , 09:15 PM






This is the first time I've tried to convert my .asp ado connection to the
..NET framework and I'm totally lost.



I'm trying to add a new record using the code below and am getting an
error - BC30518: Overload resolution failed because no accessible 'Update'
can be called with these arguments:





Dim cnObj as OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & dbPath &
";")

Dim daVisitors As OleDbDataAdapter = New
OleDbDataAdapter("SELECT * From Visitors", cnObj)

Dim dsVisitors As New DataSet()

Dim dtVisitors As DataTable

Dim drVisitors As DataRow



cnObj.Open()



daVisitors.Fill(dsVisitors, "Visitors")

dtVisitors = dsVisitors.Tables("Visitors")

drVisitors = dtVisitors.NewRow()

With drVisitors

.Item("Field1") = "Some Data"

..Item("Field2") = "Some Data 2"

End With

dtVisitors.Rows.Add(drVisitors)

daVisitors.Update(drVisitors)





cnObj.Close



Because I have little experience with ADO.Net Syntax I'm not even sure if
this is the right approach. Any help would be greatly appreciated.

CES



Reply With Quote
  #2  
Old   
Paul Whitham TMM
 
Posts: n/a

Default Re: Converting ASP Data Connections to ASP.NET - 08-02-2004 , 10:22 PM






You code there is a select statement and not an update statement. The code
below is for an update statement

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))
objCmd = New OleDbCommand("Insert INTO
tblCourseNames(CourseName,CourseOutline) VALUES (@CourseName,
@CourseOutline)", objConn)
objCmd.Parameters.Add("@CourseName", txtCourseName.Text)
objCmd.Parameters.Add("@CourseOutline", FreeTextBox1.Text)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
End Sub

This is a attached to a Button event. The line
objConn = New OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))

references the connection string that is stored in the web.config file like
this

<appSettings>
<add key="dsn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\TurtleBay\Database\Sched ule.mdb;Persist Security
Info=False" />

</appSettings>


--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote

Quote:
This is the first time I've tried to convert my .asp ado connection to the
.NET framework and I'm totally lost.



I'm trying to add a new record using the code below and am getting an
error - BC30518: Overload resolution failed because no accessible 'Update'
can be called with these arguments:





Dim cnObj as OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & dbPath &
";")

Dim daVisitors As OleDbDataAdapter = New
OleDbDataAdapter("SELECT * From Visitors", cnObj)

Dim dsVisitors As New DataSet()

Dim dtVisitors As DataTable

Dim drVisitors As DataRow



cnObj.Open()



daVisitors.Fill(dsVisitors, "Visitors")

dtVisitors = dsVisitors.Tables("Visitors")

drVisitors = dtVisitors.NewRow()

With drVisitors

.Item("Field1") = "Some Data"

.Item("Field2") = "Some Data 2"

End With

dtVisitors.Rows.Add(drVisitors)

daVisitors.Update(drVisitors)





cnObj.Close



Because I have little experience with ADO.Net Syntax I'm not even sure if
this is the right approach. Any help would be greatly appreciated.

CES





Reply With Quote
  #3  
Old   
CES
 
Posts: n/a

Default Re: Converting ASP Data Connections to ASP.NET - 08-02-2004 , 11:09 PM



Paul,

Are you accessing a query with in the access Database or are you accessing a
Table? I ask becouse I'm geting the following error:

---- Exception Details: System.Data.OleDb.OleDbException: Operation must use
an updateable query. ----

If you are going against a Query as I suspect do you know how I would modify
your code to allow updating a table???

Thanks
CES

Dim objConn As OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & dbPath &
";")
Dim objCmd As OleDbCommand = New OleDbCommand("Insert INTO
visitors(UserNum,BrowserId) VALUES (@UserNum,@BrowserId)", objConn)
objCmd.Parameters.Add("@UserNum", "userNum text")
objCmd.Parameters.Add("@BrowserId", "BrowserId Text")
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()


"Paul Whitham TMM" <paul (AT) valleybiz (DOT) net> wrote

Quote:
You code there is a select statement and not an update statement. The code
below is for an update statement

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))
objCmd = New OleDbCommand("Insert INTO
tblCourseNames(CourseName,CourseOutline) VALUES (@CourseName,
@CourseOutline)", objConn)
objCmd.Parameters.Add("@CourseName", txtCourseName.Text)
objCmd.Parameters.Add("@CourseOutline", FreeTextBox1.Text)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
End Sub

This is a attached to a Button event. The line
objConn = New OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))

references the connection string that is stored in the web.config file
like
this

appSettings
add key="dsn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\TurtleBay\Database\Sched ule.mdb;Persist Security
Info=False" /

/appSettings


--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote in message
news:cemov6$neb$1 (AT) forums (DOT) macromedia.com...
This is the first time I've tried to convert my .asp ado connection to
the
.NET framework and I'm totally lost.



I'm trying to add a new record using the code below and am getting an
error - BC30518: Overload resolution failed because no accessible
'Update'
can be called with these arguments:





Dim cnObj as OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & dbPath
&
";")

Dim daVisitors As OleDbDataAdapter = New
OleDbDataAdapter("SELECT * From Visitors", cnObj)

Dim dsVisitors As New DataSet()

Dim dtVisitors As DataTable

Dim drVisitors As DataRow



cnObj.Open()



daVisitors.Fill(dsVisitors, "Visitors")

dtVisitors = dsVisitors.Tables("Visitors")

drVisitors = dtVisitors.NewRow()

With drVisitors

.Item("Field1") = "Some Data"

.Item("Field2") = "Some Data 2"

End With

dtVisitors.Rows.Add(drVisitors)

daVisitors.Update(drVisitors)





cnObj.Close



Because I have little experience with ADO.Net Syntax I'm not even sure
if
this is the right approach. Any help would be greatly appreciated.

CES







Reply With Quote
  #4  
Old   
Paul Whitham TMM
 
Posts: n/a

Default Re: Converting ASP Data Connections to ASP.NET - 08-02-2004 , 11:50 PM



I am accessing a table. The error you are getting is because the database,
or the folder it is sitting in, does not have write access enabled for the
anonymous .net web client.

If this is on a shared host, ask you tech people to correct. If it is on a
local machine follow the steps in this tutorial
http://www.charon.co.uk/content.aspx?CategoryID=27&ArticleID=56

--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote

Quote:
Paul,

Are you accessing a query with in the access Database or are you accessing
a
Table? I ask becouse I'm geting the following error:

---- Exception Details: System.Data.OleDb.OleDbException: Operation must
use
an updateable query. ----

If you are going against a Query as I suspect do you know how I would
modify
your code to allow updating a table???

Thanks
CES

Dim objConn As OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & dbPath &
";")
Dim objCmd As OleDbCommand = New OleDbCommand("Insert INTO
visitors(UserNum,BrowserId) VALUES (@UserNum,@BrowserId)", objConn)
objCmd.Parameters.Add("@UserNum", "userNum text")
objCmd.Parameters.Add("@BrowserId", "BrowserId Text")
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()


"Paul Whitham TMM" <paul (AT) valleybiz (DOT) net> wrote in message
news:cemsml$qpt$1 (AT) forums (DOT) macromedia.com...
You code there is a select statement and not an update statement. The
code
below is for an update statement

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))
objCmd = New OleDbCommand("Insert INTO
tblCourseNames(CourseName,CourseOutline) VALUES (@CourseName,
@CourseOutline)", objConn)
objCmd.Parameters.Add("@CourseName", txtCourseName.Text)
objCmd.Parameters.Add("@CourseOutline", FreeTextBox1.Text)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
End Sub

This is a attached to a Button event. The line
objConn = New OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))

references the connection string that is stored in the web.config file
like
this

appSettings
add key="dsn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\TurtleBay\Database\Sched ule.mdb;Persist
Security
Info=False" /

/appSettings


--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote in message
news:cemov6$neb$1 (AT) forums (DOT) macromedia.com...
This is the first time I've tried to convert my .asp ado connection to
the
.NET framework and I'm totally lost.



I'm trying to add a new record using the code below and am getting an
error - BC30518: Overload resolution failed because no accessible
'Update'
can be called with these arguments:





Dim cnObj as OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" &
dbPath
&
";")

Dim daVisitors As OleDbDataAdapter = New
OleDbDataAdapter("SELECT * From Visitors", cnObj)

Dim dsVisitors As New DataSet()

Dim dtVisitors As DataTable

Dim drVisitors As DataRow



cnObj.Open()



daVisitors.Fill(dsVisitors, "Visitors")

dtVisitors = dsVisitors.Tables("Visitors")

drVisitors = dtVisitors.NewRow()

With drVisitors

.Item("Field1") = "Some Data"

.Item("Field2") = "Some Data 2"

End With

dtVisitors.Rows.Add(drVisitors)

daVisitors.Update(drVisitors)





cnObj.Close



Because I have little experience with ADO.Net Syntax I'm not even sure
if
this is the right approach. Any help would be greatly appreciated.

CES









Reply With Quote
  #5  
Old   
CES
 
Posts: n/a

Default Re: Converting ASP Data Connections to ASP.NET - 08-03-2004 , 12:09 AM



Thank You Paul, while i had permisions for the IUSR account I didn't for the
ASPNET Account.
CES
"Paul Whitham TMM" <paul (AT) valleybiz (DOT) net> wrote

Quote:
I am accessing a table. The error you are getting is because the database,
or the folder it is sitting in, does not have write access enabled for the
anonymous .net web client.

If this is on a shared host, ask you tech people to correct. If it is on a
local machine follow the steps in this tutorial
http://www.charon.co.uk/content.aspx?CategoryID=27&ArticleID=56

--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote in message
news:cemvkg$88$1 (AT) forums (DOT) macromedia.com...
Paul,

Are you accessing a query with in the access Database or are you
accessing
a
Table? I ask becouse I'm geting the following error:

---- Exception Details: System.Data.OleDb.OleDbException: Operation must
use
an updateable query. ----

If you are going against a Query as I suspect do you know how I would
modify
your code to allow updating a table???

Thanks
CES

Dim objConn As OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & dbPath
&
";")
Dim objCmd As OleDbCommand = New OleDbCommand("Insert INTO
visitors(UserNum,BrowserId) VALUES (@UserNum,@BrowserId)", objConn)
objCmd.Parameters.Add("@UserNum", "userNum text")
objCmd.Parameters.Add("@BrowserId", "BrowserId Text")
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()


"Paul Whitham TMM" <paul (AT) valleybiz (DOT) net> wrote in message
news:cemsml$qpt$1 (AT) forums (DOT) macromedia.com...
You code there is a select statement and not an update statement. The
code
below is for an update statement

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))
objCmd = New OleDbCommand("Insert INTO
tblCourseNames(CourseName,CourseOutline) VALUES (@CourseName,
@CourseOutline)", objConn)
objCmd.Parameters.Add("@CourseName", txtCourseName.Text)
objCmd.Parameters.Add("@CourseOutline", FreeTextBox1.Text)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
End Sub

This is a attached to a Button event. The line
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))

references the connection string that is stored in the web.config file
like
this

appSettings
add key="dsn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\TurtleBay\Database\Sched ule.mdb;Persist
Security
Info=False" /

/appSettings


--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote in message
news:cemov6$neb$1 (AT) forums (DOT) macromedia.com...
This is the first time I've tried to convert my .asp ado connection
to
the
.NET framework and I'm totally lost.



I'm trying to add a new record using the code below and am getting
an
error - BC30518: Overload resolution failed because no accessible
'Update'
can be called with these arguments:





Dim cnObj as OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" &
dbPath
&
";")

Dim daVisitors As OleDbDataAdapter = New
OleDbDataAdapter("SELECT * From Visitors", cnObj)

Dim dsVisitors As New DataSet()

Dim dtVisitors As DataTable

Dim drVisitors As DataRow



cnObj.Open()



daVisitors.Fill(dsVisitors, "Visitors")

dtVisitors = dsVisitors.Tables("Visitors")

drVisitors = dtVisitors.NewRow()

With drVisitors

.Item("Field1") = "Some Data"

.Item("Field2") = "Some Data 2"

End With

dtVisitors.Rows.Add(drVisitors)

daVisitors.Update(drVisitors)





cnObj.Close



Because I have little experience with ADO.Net Syntax I'm not even
sure
if
this is the right approach. Any help would be greatly appreciated.

CES











Reply With Quote
  #6  
Old   
CES
 
Posts: n/a

Default Re: Converting ASP Data Connections to ASP.NET - 08-03-2004 , 02:50 AM



Paul,
How do you deal with null Values
Like
if request("UserNum") <> "" Then
objCmd.Parameters.Add("@UserNum", "userNum text")
End If

Thanks
CES

"Paul Whitham TMM" <paul (AT) valleybiz (DOT) net> wrote

Quote:
I am accessing a table. The error you are getting is because the database,
or the folder it is sitting in, does not have write access enabled for the
anonymous .net web client.

If this is on a shared host, ask you tech people to correct. If it is on a
local machine follow the steps in this tutorial
http://www.charon.co.uk/content.aspx?CategoryID=27&ArticleID=56

--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote in message
news:cemvkg$88$1 (AT) forums (DOT) macromedia.com...
Paul,

Are you accessing a query with in the access Database or are you
accessing
a
Table? I ask becouse I'm geting the following error:

---- Exception Details: System.Data.OleDb.OleDbException: Operation must
use
an updateable query. ----

If you are going against a Query as I suspect do you know how I would
modify
your code to allow updating a table???

Thanks
CES

Dim objConn As OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" & dbPath
&
";")
Dim objCmd As OleDbCommand = New OleDbCommand("Insert INTO
visitors(UserNum,BrowserId) VALUES (@UserNum,@BrowserId)", objConn)
objCmd.Parameters.Add("@UserNum", "userNum text")
objCmd.Parameters.Add("@BrowserId", "BrowserId Text")
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()


"Paul Whitham TMM" <paul (AT) valleybiz (DOT) net> wrote in message
news:cemsml$qpt$1 (AT) forums (DOT) macromedia.com...
You code there is a select statement and not an update statement. The
code
below is for an update statement

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))
objCmd = New OleDbCommand("Insert INTO
tblCourseNames(CourseName,CourseOutline) VALUES (@CourseName,
@CourseOutline)", objConn)
objCmd.Parameters.Add("@CourseName", txtCourseName.Text)
objCmd.Parameters.Add("@CourseOutline", FreeTextBox1.Text)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
End Sub

This is a attached to a Button event. The line
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))

references the connection string that is stored in the web.config file
like
this

appSettings
add key="dsn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\TurtleBay\Database\Sched ule.mdb;Persist
Security
Info=False" /

/appSettings


--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote in message
news:cemov6$neb$1 (AT) forums (DOT) macromedia.com...
This is the first time I've tried to convert my .asp ado connection
to
the
.NET framework and I'm totally lost.



I'm trying to add a new record using the code below and am getting
an
error - BC30518: Overload resolution failed because no accessible
'Update'
can be called with these arguments:





Dim cnObj as OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" &
dbPath
&
";")

Dim daVisitors As OleDbDataAdapter = New
OleDbDataAdapter("SELECT * From Visitors", cnObj)

Dim dsVisitors As New DataSet()

Dim dtVisitors As DataTable

Dim drVisitors As DataRow



cnObj.Open()



daVisitors.Fill(dsVisitors, "Visitors")

dtVisitors = dsVisitors.Tables("Visitors")

drVisitors = dtVisitors.NewRow()

With drVisitors

.Item("Field1") = "Some Data"

.Item("Field2") = "Some Data 2"

End With

dtVisitors.Rows.Add(drVisitors)

daVisitors.Update(drVisitors)





cnObj.Close



Because I have little experience with ADO.Net Syntax I'm not even
sure
if
this is the right approach. Any help would be greatly appreciated.

CES











Reply With Quote
  #7  
Old   
Paul Whitham TMM
 
Posts: n/a

Default Re: Converting ASP Data Connections to ASP.NET - 08-03-2004 , 07:32 PM



Firstly if the field is not supposed to be blank that use validation of the
form to stop the process, and surround you update statement with

if (page.isValid) then




--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote

Quote:
Paul,
How do you deal with null Values
Like
if request("UserNum") <> "" Then
objCmd.Parameters.Add("@UserNum", "userNum text")
End If

Thanks
CES

"Paul Whitham TMM" <paul (AT) valleybiz (DOT) net> wrote in message
news:cen1qk$28a$1 (AT) forums (DOT) macromedia.com...
I am accessing a table. The error you are getting is because the
database,
or the folder it is sitting in, does not have write access enabled for
the
anonymous .net web client.

If this is on a shared host, ask you tech people to correct. If it is on
a
local machine follow the steps in this tutorial
http://www.charon.co.uk/content.aspx?CategoryID=27&ArticleID=56

--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote in message
news:cemvkg$88$1 (AT) forums (DOT) macromedia.com...
Paul,

Are you accessing a query with in the access Database or are you
accessing
a
Table? I ask becouse I'm geting the following error:

---- Exception Details: System.Data.OleDb.OleDbException: Operation
must
use
an updateable query. ----

If you are going against a Query as I suspect do you know how I would
modify
your code to allow updating a table???

Thanks
CES

Dim objConn As OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" &
dbPath
&
";")
Dim objCmd As OleDbCommand = New OleDbCommand("Insert INTO
visitors(UserNum,BrowserId) VALUES (@UserNum,@BrowserId)", objConn)
objCmd.Parameters.Add("@UserNum", "userNum text")
objCmd.Parameters.Add("@BrowserId", "BrowserId Text")
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()


"Paul Whitham TMM" <paul (AT) valleybiz (DOT) net> wrote in message
news:cemsml$qpt$1 (AT) forums (DOT) macromedia.com...
You code there is a select statement and not an update statement.
The
code
below is for an update statement

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim objConn As OleDbConnection
Dim objCmd As OleDbCommand
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))
objCmd = New OleDbCommand("Insert INTO
tblCourseNames(CourseName,CourseOutline) VALUES (@CourseName,
@CourseOutline)", objConn)
objCmd.Parameters.Add("@CourseName", txtCourseName.Text)
objCmd.Parameters.Add("@CourseOutline", FreeTextBox1.Text)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
End Sub

This is a attached to a Button event. The line
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings( "DSN"))

references the connection string that is stored in the web.config
file
like
this

appSettings
add key="dsn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\TurtleBay\Database\Sched ule.mdb;Persist
Security
Info=False" /

/appSettings


--
Regards

Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
www.valleybiz.net

Team Macromedia Volunteer for Ultradev/Dreamweaver MX
www.macromedia.com/support/forums/team_macromedia

"CES" <none (AT) none (DOT) com> wrote in message
news:cemov6$neb$1 (AT) forums (DOT) macromedia.com...
This is the first time I've tried to convert my .asp ado
connection
to
the
.NET framework and I'm totally lost.



I'm trying to add a new record using the code below and am getting
an
error - BC30518: Overload resolution failed because no accessible
'Update'
can be called with these arguments:





Dim cnObj as OleDbConnection = New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=" &
dbPath
&
";")

Dim daVisitors As OleDbDataAdapter = New
OleDbDataAdapter("SELECT * From Visitors", cnObj)

Dim dsVisitors As New DataSet()

Dim dtVisitors As DataTable

Dim drVisitors As DataRow



cnObj.Open()



daVisitors.Fill(dsVisitors, "Visitors")

dtVisitors = dsVisitors.Tables("Visitors")

drVisitors = dtVisitors.NewRow()

With drVisitors

.Item("Field1") = "Some Data"

.Item("Field2") = "Some Data 2"

End With

dtVisitors.Rows.Add(drVisitors)

daVisitors.Update(drVisitors)





cnObj.Close



Because I have little experience with ADO.Net Syntax I'm not even
sure
if
this is the right approach. Any help would be greatly appreciated.

CES













Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.