Search Results

Search found 50 results on 2 pages for 'phsika'.

Page 1/2 | 1 2  | Next Page >

  • How can I fill SQL Server table from excel only using sql query?

    - by Phsika
    How can I do that with Microsoft.ACE.OLEDB.12.0? CREATE TABLE [dbo].[Addresses_Temp] ( [FirstName] VARCHAR(20), [LastName] VARCHAR(20), [Address] VARCHAR(50), [City] VARCHAR(30), [State] VARCHAR(2), [ZIP] VARCHAR(10) ) GO INSERT INTO [dbo].[Address_Temp] ( [FirstName], [LastName], [Address], [City], [State], [ZIP] ) SELECT [FirstName], [LastName], [Address], [City], [State], [ZIP] FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\Source\Addresses.xlsx;IMEX=1', 'SELECT * FROM [Sayfa1$]') How can I do that?

    Read the article

  • How can i call method from class but this method implamented from any interface?

    - by Phsika
    i try to call base.Alan(); in HacimBul. But base. dont give intellisense alan method public double HacimBul() { throw new Exception(); //return base..... -- how can i see base.Alan(); } namespace interfaceClass { class Program { static void Main(string[] args) { } } interface Ikenar { double kenar { get; set; } } interface Iyukseklik { double yuksekli {get; set;} } interface IAlan { double Alan(); } interface IHacim { double Hacim(); } class Alan : Ikenar, IAlan { public double kenar { get; set; } double IAlan.Alan() { return kenar * kenar; } } class Hacim : Alan, Iyukseklik { public double kenar { get; set; } public double yuksekli { get; set; } public double HacimBul() { throw new Exception(); //return base..... -- how can i see base.Alan(); } } }

    Read the article

  • How can i call method from class but this method implemented from any interface?

    - by Phsika
    i try to call base.Alan(); in HacimBul. But base. dont give intellisense alan method public double HacimBul() { throw new Exception(); //return base..... -- how can i see base.Alan(); } namespace interfaceClass { class Program { static void Main(string[] args) { } } interface Ikenar { double kenar { get; set; } } interface Iyukseklik { double yuksekli {get; set;} } interface IAlan { double Alan(); } interface IHacim { double Hacim(); } class Alan : Ikenar, IAlan { public double kenar { get; set; } double IAlan.Alan() { return kenar * kenar; } } class Hacim : Alan, Iyukseklik { public double kenar { get; set; } public double yuksekli { get; set; } public double HacimBul() { throw new Exception(); //return base..... -- how can i see base.Alan(); } } }

    Read the article

  • why assign null value or another default value firstly?

    - by Phsika
    i try to generate some codes. i face to face delegates. Everythings is ok.(Look below) But appearing a warning: you shold assing value why? but second code below is ok. namespace Delegates { class Program { static void Main(string[] args) { HesapMak hesapla = new HesapMak(); hesapla.Calculator = new HesapMak.Hesap(hesapla.Sum); double sonuc = hesapla.Calculator(34, 2); Console.WriteLine("Toplama Sonucu:{0}",sonuc.ToString()); Console.ReadKey(); } } class HesapMak { public double Sum(double s1, double s2) { return s1 + s2; } public double Cikarma(double s1, double s2) { return s1 - s2; } public double Multiply(double s1, double s2) { return s1 * s2; } public double Divide(double s1, double s2) { return s1 / s2; } public delegate double Hesap(double s1, double s2); public Hesap Calculator; ----< they want me assingn value } } namespace Delegates { class Program { static void Main(string[] args) { HesapMak hesapla = new HesapMak(); hesapla.Calculator = new HesapMak.Hesap(hesapla.Sum); double sonuc = hesapla.Calculator(34, 2); Console.WriteLine("Toplama Sonucu:{0}",sonuc.ToString()); Console.ReadKey(); } } class HesapMak { public double Sum(double s1, double s2) { return s1 + s2; } public double Cikarma(double s1, double s2) { return s1 - s2; } public double Multiply(double s1, double s2) { return s1 * s2; } public double Divide(double s1, double s2) { return s1 / s2; } public delegate double Hesap(double s1, double s2); public Hesap Calculator=null; } }

    Read the article

  • SQL Server: invalid object name how to solve it?

    - by Phsika
    error returns to me in below codes: Msg 208, Level 16, State 1, Line 1 Invalid object name 'ENG_PREP'. insert into ENG_PREP VALUES('572012-01-1,572012-01-2,572012-01-3,572013-01-1,572013-01-2', '', '500', '', 'A320 P.001-A', 'Removal of the LH Wing Safety Rope', '', '', '', '0', '', 'AF', '12-00-00-081-001', '', '', '', '', '', '', '' )

    Read the article

  • sql inValid Object Name how to solve it?

    - by Phsika
    error returns to me in below codes:Msg 208, Level 16, State 1, Line 1 Invalid object name 'ENG_PREP'. insert into ENG_PREP VALUES('572012-01-1,572012-01-2,572012-01-3,572013-01-1,572013-01-2', '', '500', '', 'A320 P.001-A', 'Removal of the LH Wing Safety Rope', '', '', '', '0', '', 'AF', '12-00-00-081-001', '', '', '', '', '', '', '' )

    Read the article

  • How to Add Css style sheet on DevExpress Gridview?

    - by Phsika
    i have big problem about CssFilePath property in ASPXGridView . also used Theme Deployer. i created ASPXGRidView that is goog in 9.3.4 version not problem is occured but i upgrated my system to 2010.2 version (Last version) but GridView CssFilePath not working my GridView looks html table. How can i solve it : i converted my project devexpress 9.3.4 to 2010.2 but My Working gridView look like this:TEST.ASCX has got a DevExpress GridView. <Styles CssFilePath="../../App_Themes/Aqua/GridView/styles.css" CssPostfix="Aqua"></Styles> i see asp.net design mode Aqua mode every thing ok. But press f5 my Gridview look above! how can i see aqua style...

    Read the article

  • how can i solve "The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered."?

    - by Phsika
    i try to use get excel data from excel file. i am using office 2007 and sql 2005. i writed below codes: CREATE TABLE [dbo].[Addresses_Temp] ( [FirstName] VARCHAR(20), [LastName] VARCHAR(20), [Address] VARCHAR(50), [City] VARCHAR(30), [State] VARCHAR(2), [ZIP] VARCHAR(10) ) GO INSERT INTO [dbo].[Address_Temp] ( [FirstName], [LastName], [Address], [City], [State], [ZIP] ) SELECT [FirstName], [LastName], [Address], [City], [State], [ZIP] FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\Source\Addresses.xls;IMEX=1', 'SELECT * FROM [Sayfa1$]') Error:Msg 7403, Level 16, State 1, Line 2 The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered. How can i solve it?

    Read the article

  • How to File Transfer client to Server?

    - by Phsika
    i try to recieve a file from server but give me error on server.Start() ERROR : In a manner not permitted by the access permissions to access a socket was attempted to How can i solve it? private void btn_Recieve_Click(object sender, EventArgs e) { TcpListener server = null; // Set the TcpListener on port 13000. Int32 port = 13000; IPAddress localAddr = IPAddress.Parse("192.168.1.201"); // TcpListener server = new TcpListener(port); server = new TcpListener(localAddr, port); // Start listening for client requests. server.Start(); // Buffer for reading data Byte[] bytes = new Byte[277577]; String data; data = null; // Perform a blocking call to accept requests. // You could also user server.AcceptSocket() here. TcpClient client = server.AcceptTcpClient(); NetworkStream stream = client.GetStream(); int i; i = stream.Read(bytes, 0, 277577); BinaryWriter writer = new BinaryWriter(File.Open("GoodLuckToMe.jpg", FileMode.Create)); writer.Write(bytes); writer.Close(); client.Close(); }

    Read the article

  • Single Responsibility Principle usage how can i call sub method correctly?

    - by Phsika
    i try to learn SOLID prencibles. i writed two type of code style. which one is : 1)Single Responsibility Principle_2.cs : if you look main program all instance generated from interface 1)Single Responsibility Principle_3.cs : if you look main program all instance genareted from normal class My question: which one is correct usage? which one can i prefer? namespace Single_Responsibility_Principle_2 { class Program { static void Main(string[] args) { IReportManager raporcu = new ReportManager(); IReport wordraporu = new WordRaporu(); raporcu.RaporHazirla(wordraporu, "data"); Console.ReadKey(); } } interface IReportManager { void RaporHazirla(IReport rapor, string bilgi); } class ReportManager : IReportManager { public void RaporHazirla(IReport rapor, string bilgi) { rapor.RaporYarat(bilgi); } } interface IReport { void RaporYarat(string bilgi); } class WordRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Word Raporu yaratildi:{0}",bilgi); } } class ExcellRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Excell raporu yaratildi:{0}",bilgi); } } class PdfRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("pdf raporu yaratildi:{0}",bilgi); } } } Second 0ne all instance genareted from normal class namespace Single_Responsibility_Principle_3 { class Program { static void Main(string[] args) { WordRaporu word = new WordRaporu(); ReportManager manager = new ReportManager(); manager.RaporHazirla(word,"test"); } } interface IReportManager { void RaporHazirla(IReport rapor, string bilgi); } class ReportManager : IReportManager { public void RaporHazirla(IReport rapor, string bilgi) { rapor.RaporYarat(bilgi); } } interface IReport { void RaporYarat(string bilgi); } class WordRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Word Raporu yaratildi:{0}",bilgi); } } class ExcellRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Excell raporu yaratildi:{0}",bilgi); } } class PdfRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("pdf raporu yaratildi:{0}",bilgi); } } }

    Read the article

  • How can I solve out of memory exception in generic list generic ?

    - by Phsika
    How can i solve out of memory exception in list generic if adding new value foreach(DataColumn dc in dTable.Columns) foreach (DataRow dr in dTable.Rows) myScriptCellsCount.MyCellsCharactersCount.Add(dr[dc].ToString().Length); MyBase Class: public class MyExcelSheetsCells { public List<int> MyCellsCharactersCount { get; set; } public MyExcelSheetsCells() { MyCellsCharactersCount = new List<int>(); } }

    Read the article

  • How can i use generic list with foreach?

    - by Phsika
    if i compiled below codes error return foreach loop how can i solve it? Error:Error 1 foreach statement cannot operate on variables of type 'Sortlist.MyCalisan' because 'Sortlist.MyCalisan' does not contain a public definition for 'GetEnumerator' C:\Users\yusuf.karatoprak\Desktop\ExcelToSql\TestExceltoSql\Sortlist\Program.cs 46 13 Sortlist static void EskiMetodlaListele() { MyCalisan myCalisan = new MyCalisan(); Calisan calisan = new Calisan(); calisan.Ad = "ali"; calisan.SoyAd = "abdullah"; calisan.ID = 1; myCalisan.list.Add(calisan); foreach (Calisan item in myCalisan) { Console.WriteLine(item.Ad.ToString()); } } } public class Calisan { public int ID { get; set; } public string Ad { get; set; } public string SoyAd { get; set; } } public class MyCalisan { public List<Calisan> list { get; set; } public MyCalisan() { list = new List(); } }

    Read the article

  • How can i add list data in my object?

    - by Phsika
    Below codes run perfectly but i want to re generate simply static void YeniMethodListele() { Calisan calisan = new Calisan(){ ID=1, Ad="yusuf", SoyAd="karatoprak"}; List<Calisan> myList = new List<Calisan>(); myList.Add(calisan); MyCalisan myCalisan = new MyCalisan() { list = myList }; //myCalisan.list.Add(calisan); foreach (Calisan item in myCalisan.list) { Console.WriteLine(item.Ad.ToString()); } } } public class Calisan { public int ID { get; set; } public string Ad { get; set; } public string SoyAd { get; set; } } public class MyCalisan { public List<Calisan> list { get; set; } public MyCalisan() { list = new List<Calisan>(); } } static void YeniMethodListele() { Calisan calisan = new Calisan(){ ID=1, Ad="yusuf", SoyAd="karatoprak"}; MyCalisan myCalisan = new MyCalisan(); myCalisan.list.Add(calisan); foreach (Calisan item in myCalisan.list) { Console.WriteLine(item.Ad.ToString()); } } } public class Calisan { public int ID { get; set; } public string Ad { get; set; } public string SoyAd { get; set; } } public class MyCalisan { public List<Calisan> list { get; set; } public MyCalisan() { list = new List<Calisan>(); } }

    Read the article

  • How can i solve "An explicit value for the identity column in table"?

    - by Phsika
    if i try to add some data into my table error occurs: Error:Msg 8101, Level 16, State 1, Line 1 An explicit value for the identity column in table 'ENG_PREP' can only be specified when a column list is used and IDENTITY_INSERT is ON. insert into ENG_PREP VALUES('572012-01-1,572012-01-2,572012-01-3,572013-01-1,572013-01-2', '', '500', '', 'A320 P.001-A', 'Removal of the LH Wing Safety Rope', '', '', '', '0', '', 'AF', '12-00-00-081-001', '', '', '', '', '', '', '' )

    Read the article

  • How can I add array data in winform datagridview?

    - by Phsika
    I generated Personel[] type array from Biz.Bal.GetPersonelById("1") but if I want to add winforms, I do that like below. Is there any simple method? Like GridView.dataSource=myArray? private void Form1_Load(object sender, EventArgs e) { Form_init(); Model.Personel[] list = new Model.Personel[0]; list = Biz.BAL.GetPersonelByID("1"); dataGridView1.Rows[0].Cells[0].Value = list[0].ID; dataGridView1.Rows[0].Cells[1].Value = list[0].Ad; dataGridView1.Rows[0].Cells[2].Value = list[0].SoyAd; dataGridView1.Rows[0].Cells[3].Value = list[0].Maas; dataGridView1.Rows[0].Cells[4].Value = list[0].Departman; }

    Read the article

  • How can i solve out of Exception error in list generic ?

    - by Phsika
    How can i solve out of memory exception in list generic if adding new value foreach(DataColumn dc in dTable.Columns) foreach (DataRow dr in dTable.Rows) myScriptCellsCount.MyCellsCharactersCount.Add(dr[dc].ToString().Length); MyBase Class: public class MyExcelSheetsCells { public List<int> MyCellsCharactersCount { get; set; } public MyExcelSheetsCells() { MyCellsCharactersCount = new List<int>(); } }

    Read the article

  • How to use Profile in asp.net?

    - by Phsika
    i try to learn asp.net Profile management. But i added below xml firstName,LastName and others. But i cannot write Profile. if i try to write Profile property. drow my editor Profile : Error 1 The name 'Profile' does not exist in the current context C:\Documents and Settings\ykaratoprak\Desktop\Security\WebApp_profile\WebApp_profile\Default.aspx.cs 18 13 WebApp_profile How can i do that? <authentication mode="Windows"/> <profile> <properties> <add name="FirstName"/> <add name="LastName"/> <add name="Age"/> <add name="City"/> </properties> </profile> protected void Button1_Click(object sender, System.EventArgs e) { Profile.FirstName = TextBox1.Text; Profile.LastName = TextBox2.Text; Profile.Age = TextBox3.Text; Profile.City = TextBox4.Text; Label1.Text = "Profile stored successfully!<br />" + "<br />First Name: " + Profile.FirstName + "<br />Last Name: " + Profile.LastName + "<br />Age: " + Profile.Age + "<br />City: " + Profile.City; }

    Read the article

  • How can I create a SQL table using excel columns?

    - by Phsika
    I need to help to generate column name from excel automatically. I think that: we can do below codes: CREATE TABLE [dbo].[Addresses_Temp] ( [FirstName] VARCHAR(20), [LastName] VARCHAR(20), [Address] VARCHAR(50), [City] VARCHAR(30), [State] VARCHAR(2), [ZIP] VARCHAR(10) ) via C#. How can I learn column name from Excel? private void Form1_Load(object sender, EventArgs e) { ExcelToSql(); } void ExcelToSql() { string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Source\MPD.xlsm;Extended Properties=""Excel 12.0;HDR=YES;"""; // if you don't want to show the header row (first row) // use 'HDR=NO' in the string string strSQL = "SELECT * FROM [Sheet1$]"; OleDbConnection excelConnection = new OleDbConnection(connectionString); excelConnection.Open(); // This code will open excel file. OleDbCommand dbCommand = new OleDbCommand(strSQL, excelConnection); OleDbDataAdapter dataAdapter = new OleDbDataAdapter(dbCommand); // create data table DataTable dTable = new DataTable(); dataAdapter.Fill(dTable); // bind the datasource // dataBingingSrc.DataSource = dTable; // assign the dataBindingSrc to the DataGridView // dgvExcelList.DataSource = dataBingingSrc; // dispose used objects if (dTable.Rows.Count > 0) MessageBox.Show("Count:" + dTable.Rows.Count.ToString()); dTable.Dispose(); dataAdapter.Dispose(); dbCommand.Dispose(); excelConnection.Close(); excelConnection.Dispose(); }

    Read the article

  • Running Network Application on port Server side give me error how can i solve it?

    - by Phsika
    if i run Server App. Exception occurs: on Dinle.Start() System.Net.SocketException - Only one usage of each socket address (protocol/network address/port) is normally permitted How can i solve this error? Server.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; namespace Server { public partial class Server : Form { Thread kanal; public Server() { InitializeComponent(); try { kanal = new Thread(new ThreadStart(Dinle)); kanal.Start(); kanal.Priority = ThreadPriority.Normal; this.Text = "Kanla Çalisti"; } catch (Exception ex) { this.Text = "kanal çalismadi"; MessageBox.Show("hata:" + ex.ToString()); kanal.Abort(); throw; } } private void Server_Load(object sender, EventArgs e) { Dinle(); } private void btn_Listen_Click(object sender, EventArgs e) { Dinle(); } void Dinle() { // IPAddress localAddr = IPAddress.Parse("localhost"); // TcpListener server = new TcpListener(port); // server = new TcpListener(localAddr, port); //TcpListener Dinle = new TcpListener(localAddr,51124); TcpListener Dinle = new TcpListener(51124); try { while (true) { Dinle.Start(); Exception is occured. Socket Baglanti = Dinle.AcceptSocket(); if (!Baglanti.Connected) { MessageBox.Show("Baglanti Yok"); } else { TcpClient tcpClient = Dinle.AcceptTcpClient(); if (tcpClient.ReceiveBufferSize 0) { byte[] Dizi = new byte[250000]; Baglanti.Receive(Dizi, Dizi.Length, 0); string Yol; saveFileDialog1.Title = "Dosyayi kaydet"; saveFileDialog1.ShowDialog(); Yol = saveFileDialog1.FileName; FileStream Dosya = new FileStream(Yol, FileMode.Create); Dosya.Write(Dizi, 0, Dizi.Length - 20); Dosya.Close(); listBox1.Items.Add("dosya indirildi"); listBox1.Items.Add("Dosya Boyutu=" + Dizi.Length.ToString()); listBox1.Items.Add("Indirilme Tarihi=" + DateTime.Now); listBox1.Items.Add("--------------------------------"); } } } } catch (Exception ex) { MessageBox.Show("hata:" + ex.ToString()); } } } }

    Read the article

  • how can i write line by line in txt data?

    - by Phsika
    I try to write line by line data but. if i run my application. writng last text1 data in script.txt private void button1_Click(object sender, EventArgs e) { System.IO.TextWriter tw; tw = new StreamWriter("C:/Script.txt"); tw.WriteLine(textBox1.Text); tw.Close(); }

    Read the article

  • How can i learn file name and create a folder?

    - by Phsika
    i try to make TCP/Ip Application to listen any other roemote computer to recieve any file. So i try to get files. i can do that. on the other hand every sample on google about giving SaveDialogBox to recived path folder.Forexample my old server.cs is that: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; namespace Server3 { public partial class Form1 : Form { Thread kanal; public Form1() { InitializeComponent(); try { kanal = new Thread(new ThreadStart(Dinle)); kanal.Start(); kanal.Priority = ThreadPriority.Normal; this.Text = "Kanal Çalisti"; } catch (Exception ex) { this.Text = "kanal çalismadi"; MessageBox.Show("hata:" + ex.ToString()); kanal.Abort(); throw; } } void Dinle() { TcpListener server = null; try { Int32 port = 51124; IPAddress localAddr = IPAddress.Parse("127.0.0.1"); server = new TcpListener(localAddr, port); server.Start(); Byte[] bytes = new Byte[1024 * 250000]; // string ReceivedPath = "C:/recieved"; while (true) { MessageBox.Show("Waiting for a connection... "); TcpClient client = server.AcceptTcpClient(); MessageBox.Show("Connected!"); NetworkStream stream = client.GetStream(); if (stream.CanRead) { saveFileDialog1.ShowDialog(); string pathfolder = saveFileDialog1.FileName; StreamWriter yaz = new StreamWriter(pathfolder); string satir; StreamReader oku = new StreamReader(stream); while ((satir = oku.ReadLine()) != null) { satir = satir + (char)13 + (char)10; yaz.WriteLine(satir); } oku.Close(); yaz.Close(); client.Close(); } } } catch (SocketException e) { Console.WriteLine("SocketException: {0}", e); } finally { // Stop listening for new clients. server.Stop(); } Console.WriteLine("\nHit enter to continue..."); Console.Read(); } private void Form1_Load(object sender, EventArgs e) { Dinle(); } } } i want to give automatically folder without SAVEDIALOGBOX. Also i want to learn my file name om my stream.Like that: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; namespace Server3 { public partial class Form1 : Form { Thread kanal; public Form1() { InitializeComponent(); try { kanal = new Thread(new ThreadStart(Dinle)); kanal.Start(); kanal.Priority = ThreadPriority.Normal; this.Text = "Kanal Çalisti"; } catch (Exception ex) { this.Text = "kanal çalismadi"; MessageBox.Show("hata:" + ex.ToString()); kanal.Abort(); throw; } } void Dinle() { TcpListener server = null; try { Int32 port = 51124; IPAddress localAddr = IPAddress.Parse("127.0.0.1"); server = new TcpListener(localAddr, port); server.Start(); Byte[] bytes = new Byte[1024 * 250000]; string ReceivedPath = "C:/recieved"; while (true) { MessageBox.Show("Waiting for a connection... "); TcpClient client = server.AcceptTcpClient(); MessageBox.Show("Connected!"); NetworkStream stream = client.GetStream(); if (stream.CanRead) { saveFileDialog1.ShowDialog(); string pathfolder = " i have to give property creating path and want to learn file name"; StreamWriter yaz = new StreamWriter(pathfolder); string satir; StreamReader oku = new StreamReader(stream); while ((satir = oku.ReadLine()) != null) { satir = satir + (char)13 + (char)10; yaz.WriteLine(satir); } oku.Close(); yaz.Close(); client.Close(); } } } catch (SocketException e) { Console.WriteLine("SocketException: {0}", e); } finally { // Stop listening for new clients. server.Stop(); } Console.WriteLine("\nHit enter to continue..."); Console.Read(); } private void Form1_Load(object sender, EventArgs e) { Dinle(); } } } Also i need : FileStream fs; FileInfo fi = new FileInfo(@"c:/recieved"); if (fi.Exists) fs = new FileStream(fi.FullName, FileMode.Append); else fs = new FileStream(fi.FullName, FileMode.Create); StreamWriter yazici = new StreamWriter(fs); How can i do that. Creating C:/recieved if it does not exist. And how can i learn File name on my network stream sending File Name.

    Read the article

  • How can i return dataset perfectly from sql?

    - by Phsika
    i try to write a winform application: i dislike below codes: DataTable dt = new DataTable(); dt.Load(dr); ds = new DataSet(); ds.Tables.Add(dt); Above part of codes looks unsufficient.How can i best loading dataset? public class LoadDataset { public DataSet GetAllData(string sp) { return LoadSQL(sp); } private DataSet LoadSQL(string sp) { SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"].ToString()); SqlCommand cmd = new SqlCommand(sp, con); DataSet ds; try { con.Open(); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); ds = new DataSet(); ds.Tables.Add(dt); return ds; } finally { con.Dispose(); cmd.Dispose(); } } }

    Read the article

  • Howw to add new value with generic Repository if there are foreign keys (EF-4)?

    - by Phsika
    i try to write a kind of generic repository to add method. Everything is ok to add but I have table which is related with two tables with FOREIGN KEY.But Not working because of foreign key public class DomainRepository<TModel> : IDomainRepository<TModel> where TModel : class { #region IDomainRepository<T> Members private ObjectContext _context; private IObjectSet<TModel> _objectSet; public DomainRepository() { } public DomainRepository(ObjectContext context) { _context = context; _objectSet = _context.CreateObjectSet<TModel>(); } //do something..... public TModel Add<TModel>(TModel entity) where TModel : IEntityWithKey { EntityKey key; object originalItem; key = _context.CreateEntityKey(entity.GetType().Name, entity); _context.AddObject(key.EntitySetName, entity); _context.SaveChanges(); return entity; } //do something..... } Calling REPOSITORY: //insert-update-delete public partial class AddtoTables { public table3 Add(int TaskId, int RefAircraftsId) { using (DomainRepository<table3> repTask = new DomainRepository<table3>(new TaskEntities())) { return repTask.Add<table3>(new table3() { TaskId = TaskId, TaskRefAircraftsID = RefAircraftsId }); } } } How to add a new value if this table includes foreign key relation

    Read the article

1 2  | Next Page >