Connectivity of ASP.NET 2.0 with SQL server 2000

  • Thread starter Trivedi Chinkal
  • Start date
T

Trivedi Chinkal

Hello Friends,

I am learning ASP.NET 2.0 myself. So, I have problem for connention of
ASP.NET 2.0 with SQL server 2000 that I cant understand that So, which thing
helpful for me about this connetion Or which thing I have to learn for that
please tell me.

Thanks.
 
C

Cowboy \(Gregory A. Beamer\)

Here is a simple pattern, using a dataset. I am including the entire class,
to make things easier. This is a bit of a strange pattern in some ways, but
it matches the other methodology of other classes (using table adapters), so
it will make things easier for the Junior devs who might take over the code.

The table mappings here are a bit heavy, but the basic model should work for
you if you use strongly typed datasets. I have more info on why this one is
patterned this way at:
http://gregorybeamer.spaces.live.com/blog/cns!B036196EAF9B34A8!974.entry

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using Microtrak.UnitWarehouse.Data.DataSets;

namespace Microtrak.UnitWarehouse.Data.Repositories
{
public class UnitInfoRepository
{
private string _connectionString;

public UnitInfoRepository(string connectionString)
{
_connectionString = connectionString;
}

public UnitInfoDS GetUnitInformationByImei(string imei)
{
var ds = new UnitInfoDS();

var connection = new SqlConnection(_connectionString);
var command = new SqlCommand("FillUnitInfoDataSetByIMEI",
connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@IMEI", imei);

//Set table mappings
var da = new SqlDataAdapter(command);
da.TableMappings.Add("Table", "Unit");
da.TableMappings.Add("Table1", "UnitModelType");
da.TableMappings.Add("Table2", "UnitManufacturerType");
da.TableMappings.Add("Table3", "Product");
da.TableMappings.Add("Table4", "ProductLine");
da.TableMappings.Add("Table5", "Project");
da.TableMappings.Add("Table6", "PID");
da.TableMappings.Add("Table7", "FirmwareVersionType");
da.TableMappings.Add("Table8", "APN");
da.TableMappings.Add("Table9", "SIM");
da.TableMappings.Add("Table10", "ShippingCarton");
da.TableMappings.Add("Table11", "Script");
da.TableMappings.Add("Table12", "FriendIpAddressGroup");
da.TableMappings.Add("Table13", "FriendIpAddress");

try
{
connection.Open();
da.Fill(ds);
}
catch (Exception)
{

throw;
}



return ds;
}

}
}
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top