本文介绍了使用dot net应用程序连接到Teradata数据库服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我将使用点网应用程序连接到Teradata数据库服务器,我发现Teradata的点网数据提供程序,您能否提供连接到该DB服务器的示例代码,并从内部调用过程甚至选择语句我的应用程序中,您可以在下面的代码中找到我的第一个足迹:
Hi All,
I''m gonna connect to a Teradata database server using a dot net application, I have found that Dot net data provider for Teradata, can you provide a sample code connecting to that DB server, and calling procedures or even a select statement from inside my application, you can find herunder my first foot print in code in this:
class Constants
{
// Name of the Teradata Database user able to create, drop, and manipulate tables
public static readonly String sUser = "UserName";
public static readonly String sPassword = "Password";
public static readonly String sDataSource = "IP Address";
public static readonly String sConnection = "Data Source=" + sDataSource + ";User ID=" + sUser + ";Password=" + sPassword;
}
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DbProviderFactory pf = DbProviderFactories.GetFactory("Teradata.Client.Provider");
DbConnection con = pf.CreateConnection();
con.ConnectionString = Constants.sConnection;
DbCommand cmd= new DbCommand("select top 10 * from tdb.access_method");
DbCommand Db = (DbCommand)cmd;
Db.Connection = con;
DataSet ds = new DataSet();
con.Open();
string tt = (string)Db.ExecuteScalar();
Response.Write("<Script> alert('" + tt + "'); </Script>");
}
}
问候,
Ahmed Gad
regards,
Ahmed Gad
推荐答案
这篇关于使用dot net应用程序连接到Teradata数据库服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!