Re: Questions regarding C#
For no 4. Here are some Links
http://www.deitel.com/Books/VisualC2...6/Default.aspx
here download the Code examples into Your computer. There Are tons of useful example Programs Project including drawing and shapes. You just go through all the examples, many of this will surely help you....
http://msdn.microsoft.com/en-us/magazine/cc721604.aspx
http://stackoverflow.com/questions/1...rawing-program
http://social.msdn.microsoft.com/For...7-8fff11b4139c
Re: Questions regarding C#
Thanks, will look at this links right away!
Looking forward to getting more links/tuts/samples on all of the questions above.
Re: Questions regarding C#
To create the local DB:
In the menu bar click View->Server Explorer.
In the Server Explorer right click Data Connections and click add connection
Select Microsoft SQL Server Database File
Give the DB a name, a save it to you harddrive.
To create tables in the database file:
click the plus on the newly created database connection
right click tables and select Add New Table
input the table structure
To add the database to the project:
In the Solution Explorer right click your project and select Add->New Item
Select LINQ to SQL Classes, name it and click Add
Double click the newly created item in the Solution Explorer
Now drag the table from the Server Explorer into the middle of VS (the white space that is now there)
You will be asked if you would like to add the Database Connection to the project, select Yes.
Now you sould see a model of you table.
Save the .dbml file
To interact with the database:
create a new database object:
Code:
var db = new dbDataContext(); // if your .dbml file is called db
var db = new databaseDataContext(); // if your .dbml file is called database
Now you can access the data in the database using LINQ to SQL
e.g.:
Code:
var row = db.SomeTable.Where(a => a.id == 4); // SELECT * FROM SomeTable WHERE 'id' = '4';
Re: Questions regarding C#
Thank you for the answers. Still looking forward to getting more things!
About that database. Can you give me an example about:
A databse nammed testdb
A table named users
with columns: ID and User
Lets say I have winforms application with 2 text boxes and 2 buttons. When I enter the User text in textBox1 and press button1, it will import the data from it into the DB (under ID 1, if and using autoincrease). And when I click button 2, it will show the data where the ID is 1 to textBox2.
Thanks in advance!
Re: Questions regarding C#
Quote:
A databse nammed testdb
A table named users
with columns: ID and User
Lets say I have winforms application with 2 text boxes and 2 buttons. When I enter the User text in textBox1 and press button1, it will import the data from it into the DB (under ID 1, if and using autoincrease). And when I click button 2, it will show the data where the ID is 1 to textBox2.
something like this:
Code:
private void button1_Click(object sender, EventArgs e)
{
var db = new testdbDataContext();
db.Users.InsertOnSubmit(new User() { User1 = textBox1.Text }); //ID is auto assigned and incremented
db.SubmitChanges();
}
private void button2_Click(object sender, EventArgs e)
{
var db = new testdbDataContext();
var user = db.Users.Single(a => a.ID == 1); // get the user with ID = 1
textBox2.Text = user.User1;
}
The autogenerated names of the columns in the table might differ from the names that you have given the columns in the database.
In this case it is because the table and the column shares the same name.
It would make more sense to call the column 'username' or something like that.
Re: Questions regarding C#
I am working with databse: databse
table: Users
Columns: ID (primary key, auto increase), Username and Password
I am using the following code:
var db = new databaseDataContext();
db.Users.InsertOnSubmit(new User() { Username = textBox1.Text }); //ID is auto assigned and incremented
db.SubmitChanges();
It is not inserting any values in the DB, but I can't understand waht is this doing:
db.Users.InsertOnSubmit(new User() { Username = textBox1.Text });
especially the thing "new User()", as I don't have anything ithe DB called 'User' and IF i change it to anything else i get errors... I will be glad If you can tell me why it is not working and what does that row mean.
Thanks for the answers.
PS. Maybe we can talk over on msn/skype, in case I have mroe answers and you don't mind answering them..
Re: Questions regarding C#
I am working on similar project too, so was also a great help for me too....but now my problem is little diffrent.....
in table users I have 2 columns called username and password...I have already Inserted a value for each columns....I dont have any Intention to adding further data to it for now....I now want to store these values of Username and password from the database and store it in the string variavles (say s1 and s2)......Please Help me here
Re: Questions regarding C#
I have successfully got that value and stored it in string....like in
Code:
var usrnm = db.usrInfo_tables.FirstOrDefault();
string uname = usrnm.Username.ToString();
MessageBox.Show(uname);
But after this I changed the value of username from table from server explorer but the message box showed the earlier value....what should I do to change the value in database and in the program too??
Re: Questions regarding C#
I have noticed an delay on this. The program just doesen't seem to show the right that right away, you need to turn it off, refress the DB, wait a couple of seconds and than turn it on again. Don't know why's that and I honestly don't care.
Sorry for beeing rude, but this is my topyc and I don't like it beeing spammed!
Re: Questions regarding C#
What?? you mean you dont like me getting involved in your thread??
Re: Questions regarding C#
Um, why don't you make ur own thread for asking questions??
Re: Questions regarding C#
You are going all wrong here! Since I was working on almost same project here i thought it would be better if I would also participate in this discussion coz it would help both of us...BTW this is an public discussion forum where we all share the knowledge we have with others....Some people here are highly qualified professionals who spend their valuable time helping the one who want to learn like you and me.....Remember they are not your personal tutors.....I have not messed up your problems or taken your topic to another path....I just continued your thread coz I thought our problem was similar............anyway I will not continue this thread from now....Take care! and stop treating this forum as your personal Homepage
Re: Questions regarding C#
Quote:
Originally Posted by
rocky_upadhaya
You are going all wrong here! Since I was working on almost same project here i thought it would be better if I would also participate in this discussion coz it would help both of us...BTW this is an public discussion forum where we all share the knowledge we have with others....Some people here are highly qualified professionals who spend their valuable time helping the one who want to learn like you and me.....Remember they are not your personal tutors.....I have not messed up your problems or taken your topic to another path....I just continued your thread coz I thought our problem was similar............anyway I will not continue this thread from now....Take care! and stop treating this forum as your personal Homepage
I am sorry about this, but I don't think our problems were similar. Anyway you are right about the forums - this is a community, but the things you have written help me in no way.
Thanks anyway if you thought you can help.
Re: Questions regarding C#
No! I have implemented all the suggestion of jonlist and my project is similar to your's have a look at my thread "starting Datatbase" http://www.codeguru.com/forum/showthread.php?t=492538 the difference is how we implement it....wish I could help you but like new I am also new to this language and this is my first database application download and evaluate mine project....