borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (ADO.net book)Next Topic (database connection) New Topic New Poll Post Reply
AndreaVB Forum : ASP.Net : i cat insert data into the database
Poster Message
Shaik
Level: Graduate

Registered: 02-11-2005
Posts: 10

icon i cat insert data into the database

I have develope an page in ASP.net and created an database to add data into database. I have also written codes to inset data into the db via an textbox i have created. But its not adding. Even my teachers and lecturers cant solve this problem..can u??
thanks a lot. The code is as follows


Private Sub btnPost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPost.Click
    
               Dim info As String = txtInfo.Text

        Dim objDbMgmt As New DbMgmt
        objDbMgmt.Connect()

        Dim strSqlCmd As String
        Dim objDataReader As OleDb.OleDbDataReader
      
        strSqlCmd = "INSERT INTO MonthAndEvent (Information) VALUES" + "('" + info + "')" + "WHERE EventID = '29'"
        objDbMgmt.ExecuteNonQuery(strSqlCmd)
        objDbMgmt.Close()
    End Sub

[Edited by Shaik on 16-11-2005 at 03:20 AM GMT]

16-11-2005 at 03:19 AM
View Profile Send Email to User Show All Posts | Quote Reply
Bharathi
Level: Scholar

Registered: 11-04-2005
Posts: 31
icon Re: i cat insert data into the database

Hi,

Follow these steps:

1.Create and pen a dtaabase connection.
2.Create a database command that represents the SQL Insert statement to execute
3.Execute the command with the ExecuteNonQuery() method.


Dim conAuthors As OleDbConnection
Dim strInsert As string
Dim cmdInsert As OleDbCommand

conAuthors=New OleDbConnection("Provider=Microsoft.Jet,OLEDB.4.0; Data Source=c:\Authors.mdb")

strInsert="Insert INTO Authors(au_fname,au_lname) Values ('Bert','Kare')"
cmdInsert= New OleDbCommand(strInsert,conAuthors)
conAuthors.Open()
cmdInsert.ExecuteNonQuery()
conAuthors.close()


Try these steps. Write the error.

Try this Book

"Develop an Accounting Web Application using ASP.Net"


Good luck

Regards
bhar

21-11-2005 at 05:07 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : ASP.Net : i cat insert data into the database
Previous Topic (ADO.net book)Next Topic (database connection) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder