Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

SPS2003 web parts: Make a SQL connection in C#?

  Asked By: Diamond    Date: Mar 14    Category: Sharepoint    Views: 981

Having trouble making a basic SQL connection to the pubs database
using C#. Here's my code:

public class WebPart1 : WebPart
{
public WebPart1()
{
SqlConnection mMyConnection = new SqlConnection
("server=localhost;uid=extranetuser;pwd=extranetuser;database=pubs");
SqlCommand mMyCommand = new SqlCommadn("SELECT * from
publishers", mMyConnection);
SqlDataReader mMyReader;
mMyReader = mMyCommand.ExecuteReader();
}
}

Problem is, this will compile but not render in SPS. When I attempt
to drag it to the page I get the error: "One of the properties of the
Web Part has an incorrect format..."

What's going wrong? Does anyone out there have some basic code that
does SQL or ADO connections to external databases?

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on SPS2003 web parts: Make a SQL connection in C#? Or get search suggestion and latest updates.




Tagged: