how do to do this in asp.net?

L

Lasse Edsvik

Hello

ive tried to do the following in asp.net using C# but ive looked at articles
and they have according to me so many lines of code it makes no sense. could
you guys help me with following? i need it as ole-db


<%
set conn=server.createobject("adodb.connection")
conn.open "Provider=SQLOLEDB.1;Persist Security
Info=False;UID=myuser;pwd=mypass;Initial Catalog=lab;server=192.168.8.5"
sql="EXEC MyProc"
Set RS=conn.execute(sql)
%>


TIA
/Lasse
 
M

Martin Dechev

Hi, Lasse Edsvik,

You should have a look at the following classes:

System.Data.OleDb.OleDbConnection class:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataOleDbOleDbConnectionClassTopic.asp
The example in the article in fact does what you need.

System.Data.OleDb.OleDbCommand class:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataOleDbOleDbCommandClassTopic.asp

Most probably the connection string you have will work, but for more working
connection strings see:
http://www.connectionstrings.com

Greetings
Martin
 
J

Jose Marcenaro

Try this block:

using (System.OleDb.OleDbConnection conn = new System.OleDb.OleDbConnection(
"Provider=SQLOLEDB.1;Persist Security
Info=False;UID=myuser;pwd=mypass;Initial Catalog=lab;server=192.168.8.5"))
{
using (System.OleDb.OleDbCommand cmd = new
System.OleDb.OleDbCommand("EXEC MyProc",conn) {
conn.Open();
System.Data.DataSet ds = cmd.ExecuteDataSet();
}
}

Regards
Jose.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top