473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Creating database in SQL 2000 and connecting it in .Net

Hello All,
I am unable to create a new database in SQL 2000. Please tell me how to do that. Once the database is created i want to have a connection string to connect SQL in .Net in C#
Aug 11 '11 #1
10 1356
If you're using VS2005/08/10 then it's easy to create and populate the database - the wizard is the way to go. The hard part is connecting to the database. This is how I do it for SQL2008

Expand|Select|Wrap|Line Numbers
  1. SqlConnection sql = new SqlConnection();
  2. sql.ConnectionString = "Data Source=.\\SQLExpress;" + "AttachDbFilename=<your filename with the path>;" + "Integrated Security=True;" + "User Instance=True;";
  3. using (SqlCommand sqlc = sql.CreateCommand())
  4. {
  5.   // sql stuff
  6.   sql.Open();
  7.   sqlc.ExecuteNonQuery(); // or ExecuteQuery if it returns something
  8.   sql.Close();
  9. }
  10.  
An example of the filename bit

Expand|Select|Wrap|Line Numbers
  1. C:\\Users\\paul\\Documents\\visual studio 2010\\Projects\\app_name\\app_name\\App_Data\\database_name.mdf
  2.  
Probably lots of other ways to do it...
Aug 11 '11 #2
Thanks Paul.

I could solve the problem by different approach.

Select Enterprise manager in case of SQL Server 2000 or SQL Server Management Studio in case of SQL Server 2005, then by right clicking on database, one can create new database.

connection string is as follows:
Expand|Select|Wrap|Line Numbers
  1. SqlConnection cn;
  2. string str;
  3. str="Data Source=PC Name; Initial Catalog=Database Name;" + 
  4. "Integrated Security=True";
  5. cn=new SqlConnection(str);
  6.  
Aug 12 '11 #3
Thanks for the tip off :)
Aug 12 '11 #4
I am getting an error while opening the connection:
Expand|Select|Wrap|Line Numbers
  1. cn=new SqlConnection(str)
  2. cn.open();
:
Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection
Aug 13 '11 #5
Try the connection string I used (obviously, modify it first)
Aug 13 '11 #6
Its not working, someone please help me with it.
Aug 14 '11 #7
What are you using for the connection string and more over, how have you got MSSQL configured? Do you need a logon or are you using the default of windows logon?
Aug 14 '11 #8
I am using default windows login and connection string is same as i have written in earlier post.
Aug 15 '11 #9
Try using the connection string I posted. MSSQL can be a pain at times and I know that for all of my uses, it works.
Aug 15 '11 #10
Its working now, earlier i had forgotten to give semicolon after database name.
Aug 16 '11 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dinesh Garg | last post by:
Hi All, I want to use MS sql server edition 2000. I have installed the server. Now i want to create the database on this server with tables and triggers. Can please someone suggest me how to do...
3
by: Robin Tucker | last post by:
Hi there, I have a database on my test machine that will need to be installed on users machines. I would like to create the database with the given schema on the users machine and also with...
3
by: arfanameer | last post by:
How can I create a new database on sql server using OSQL command in command prompt. I have the sql file for database creation and I use the following command C:\> osql -S servername -U sa -i...
0
by: Mary Lei | last post by:
After instaling db2 8.2.2 on a solaris box I ran a script that drops a database and then creates it. This scripts runs fine under db2 8.2.1 on linux. With 8.2.2 I got a mysterious error about...
5
by: Scott Simonson | last post by:
I have a client that has asked me to modify an existing Access MDB. My question is they want me to populate their SQL server(2000 I believe). How can I accomplish this in Access 2000? Are there...
3
by: Erik Thorsen | last post by:
Hello! I am in the process of creating a database listing tours, something similar to what you can find on www.infohub.com. This means that I need to create a database which can be searchable...
6
by: di | last post by:
Does anyone have any recommendations on Examples or experience on creating a multilevel commission in Access Database. I realize this can be a very complicated set up so would like some advise....
2
by: Robin | last post by:
When I try to create a new database, I receive the following error: " ADO error:' SQL Server does not exist or access denied " Any sugguestions??
1
by: ROO | last post by:
Hi Everyone, I need some help Creating Database Connection at runtime and writing Connection String to App.Config, I have 3mxtboxes on a form txtUsername = SQL admin User txtPassword = Sql admin...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.