Solved

How do i change this insert from into a access db to an sql in asp.net

Posted on 2004-03-29
1
127 Views
Last Modified: 2012-05-04
I have the below code inserting data into an access database nit I not sure what needed to be changed to make it insert the data into an sql db.

Dim strConn as string ="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("db/emails.mdb") & ";"
Dim conn As New OLEDBConnection(strConn)
Dim cmdinsert As OLEDBCommand

cmdInsert = New OLEDBCommand("Insert into emaildet (name, email) VALUES ('" + Request.Params("name") + "','" + Request.Params("email") + "')", conn)
conn.Open()
cmdInsert.ExecuteNonQuery()
conn.close

Thanks in advance
0
Comment
Question by:dexine
1 Comment
 
LVL 35

Accepted Solution

by:
YZlat earned 125 total points
ID: 10710132
Dim strConn as string ="PROVIDER=SQLOLEDB;DATA SOURCE=sqlservername;UID=username;PWD=password;DATABASE=databasename "

Dim conn As New SQLConnection(strConn)
Dim cmdinsert As SQLCommand

cmdInsert = New SQLCommand("Insert into emaildet (name, email) VALUES ('" + Request.Params("name") + "','" + Request.Params("email") + "')", conn)
conn.Open()
cmdInsert.ExecuteNonQuery()
conn.close

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now