Hi,


I have dettach my database from SQL server2005 and attach it on Visual Studio2008. and then make the connections. when i run the program it shows the data is avaliable but when i stop the program and then run it.it show u dosent have any data why its happends. what should i do to store the data in database. Is there is any way to see the data store in the database.

i designed a crystal report it also dosent show any data. ih shows only text which i have taken.


If You know any think about it please tell me, I really neet it......


Thank You


swap123

I just want to clarify here...

You're saying you detached your DB from SQL Server 2005 and attached it on VS 2008. So, did you convert it to a flat DB file? or did you re-mount it on SQL Server 2008 (assuming you installed with VS 2008 but I could be wrong)?

Can you provide code snippets to show your connections to the DB and the procedures you're using to retrieve/store the data so we can possibly try to troubleshoot them please?

thank u for reply

I have create a new database in SQL Server 2005 and create the tables in that, after that i dettach the databse form SQl Server and then in Visual Studio 2008 I perform following task

In Solution Explorer - right click on project - add - Existing Item - from (C:\program files\sql server\mysql\data\select database with mdf and ldf) - add
after adding the databse it automatically create the datasets and TableAdopter when I select the text box and then in proprety explorer databinding - text - select feild

I hope now u know the what task i perform

please tell me..

Thank U

Swap123

I just tried to replicate using my Visual C# 2010 Express with an unmounted database I grabbed off of my MS SQL Server 2008.

I imported the unmounted DB into a test project I use when trying to troubleshoot for posts here and had no difficulty reading from and updating information in the unmounted DB. I ran the test app, closed it, ran it again, closed VS altogether, re-opened it, re-ran the app...

Unless you can provide some code examples of what it is you are trying to do and how you're coding it I'm just not finding myself able to replicate the problem you're describing at this time, I'm sorry.

Ok here is my code where i have perform save and delete operations.

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.Data.SqlClient;

namespace Shop
{
    public partial class Form3 : Form
    {
        DataTable dt;
        DataRow dr;
        public Form3()
        {
            InitializeComponent();
        }



        private void button6_Click(object sender, EventArgs e)
        {
            int dis=0,amt;
            int net;  

          //  dis = Convert.ToInt32(textBox9.Text);
            amt = Convert.ToInt32(textBox4.Text);
           // net = Convert.ToInt32(textBox8.Text);
           if(amt <=1000)
    dis=(amt*10)/100;
    else if(amt > 1000 && amt <= 2000)
           {
    dis=(amt*15)/100;
    }
    else if(amt > 2000 && amt <= 5000)
           {
               dis=(amt*20)/100;
    }
    else
    dis=(amt*22)/100;

    net=amt-dis;
    textBox8.Text = net.ToString();

            }

        private void Form3_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'bookDataSet1.details' table. You can move, or remove it, as needed.
            this.detailsTableAdapter1.Fill(this.bookDataSet1.details);
            // TODO: This line of code loads data into the 'bookDataSet.details' table. You can move, or remove it, as needed.
            //this.detailsTableAdapter.Fill(this.bookDataSet.details);

        }


        private void button2_Click(object sender, EventArgs e)// this is for save
        {

[B]//SqlConnection cn = new SqlConnection();
          //  cn.ConnectionString = "Data 
//Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\book.mdf;Integrated 
//Security=True;User Instance=True";[/B]      
      [B]cn.Open();[/B]
[B]//This connection string i have not used while programming I just written it because
// u can under stand the path where i have my database[/B]            dt = bookDataSet1.Tables["details"];
            dr = dt.NewRow();
            dr["cat"] = textBox1.Text;
            dr["nm"] = textBox2.Text;
            dr["auth"] = textBox3.Text;
            dr["cst"] = textBox4.Text;
            dr["avlstk"] = textBox5.Text;
            dr["qut"] = textBox6.Text;
            dr["remstk"] = textBox7.Text;
            dr["tot"] =textBox8.Text;
            dr["dt"] = dateTimePicker1.Text;

            DialogResult result = MessageBox.Show("You Want To Save Data", "Save", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                MessageBox.Show("The Data Is Saved", "save");
                dt.Rows.Add(dr);
                detailsTableAdapter1.Update(bookDataSet1);
                this.detailsTableAdapter1.Fill(this.bookDataSet1.details);
            }
            if (result == DialogResult.No)
            {
                MessageBox.Show("The Data Is Not Saved", "Save");
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            string code;
            code = textBox1.Text;
            dr = bookDataSet1.Tables["details"].Rows.Find(code);

            //   dr = hospitalDataSet1.Tables["doc"].Rows.Find(code);
            DialogResult result = MessageBox.Show("Are You Sure You Want To Delete Data", "Delete", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                MessageBox.Show("The Data You Have Selected Is Deleted", "Delete");
                dr.Delete();
            }
            if (result == DialogResult.No)
            {
                MessageBox.Show("The Data Is Not Deleted", "Delete");
            }


             detailsTableAdapter1.Update(bookDataSet1);

        }

        private void button5_Click(object sender, EventArgs e)
        {
            Form4 fr4 = new Form4();
            fr4.Show();

        }

        private void fillByToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.detailsTableAdapter1.FillBy(this.bookDataSet1.details, catToolStripTextBox.Text);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }


       }
    }

Thank U
Swap123

Edited 3 Years Ago by Reverend Jim: Fixed formatting

hi,

Is the dettach and attach procedure is correct if not please tell me what i should do to save the data in database because while setup there is no way to add database in our project or without having database data can not be store in SQl server will not store the data when i create a setup it show me an error message that SQL server cant have the data in database"

Please Helpme to over come this problem...

Swap123

I do apologize but at this point I'm just not spotting the issue per-se... it's almost 3am here and I think my brain's shut down for the night. Hopefully someone else will be able to help you sooner than later with the information you've provided here.

Sorry I wasn't able to be of more help :(

Ok,

I am sorry. But i am very helpless because i dont know what to do.

when i make the setup of my project it work on my PC. But when i setup the project on another PC it show the error that u dont have database.

what task i have perform to get a databse on my project.

This article has been dead for over six months. Start a new discussion instead.