TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Resmy Ravi
NA
128
0
Executing script in sql server using c# code
Oct 12 2010 5:27 AM
hi experts..
I need to execute a script in sql server using c#.i have used this code
string
sqlConnectionString =
@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=FinAccounts;Data Source=computer3\\SQLEXPRESS"
;
FileInfo
file =
new
FileInfo
(
@"E:\SQLQuery3.sql"
);
string
script = file.OpenText().ReadToEnd();
MessageBox
.Show(script.ToString());
SqlConnection
conn =
new
SqlConnection
(sqlConnectionString);
Server
server =
new
Server
(
new
ServerConnection
(conn));
server.ConnectionContext.ExecuteNonQuery(script);
file.OpenText().Close();
but an error "Failed to connect to the server" appears...what is the problem.
what should i change in the code?..please replay...
Reply
Answers (
3
)
Using the generic type 'System.Collections.Generic.IEnumerable
' requires '1' type arguments
save picture box image into one folder