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
mohamed ajmeer
NA
28
61.8k
how to execute sql query from text file using c#.net 2008
Apr 10 2011 3:38 AM
SQL QUERY:
...............................
CREATE
DATABASE [finaltest12]
go
CREATE
TABLE finaltest12.dbo.stud(name varchar(20))
go
insert
into finaltest12.dbo.stud values('ajm')
go
.....................................................................
The above SQL query iam saved in text file(test.txt) in c#2008
if i call and execute the programe, the
error come on ''go''
,how can i call and execute the query through c#2008.
my c#.net programe:
.....................................
protected void Button1_Click1(object sender, EventArgs e)
{
String createQuery;
SqlConnection con = new SqlConnection("server= JOMANA-PC\\SQLEXPRESS; user id= sa; password= ; ");
string filename="C:\\Users\\Jomana\\Documents\\Visual Studio 2008\\Projects\\createdatabase\\test.txt";
if (System.IO.File.Exists(filename) == true)
{
System.IO.
StreamReader objreader;
objreader =
new System.IO.StreamReader(filename);
createQuery = objreader.ReadToEnd();
objreader.Close();
SqlCommand myCommand = new SqlCommand(createQuery, con);
con.Open();
myCommand.ExecuteNonQuery();
con.Close();
Response.Write(
"<script>alert('Database Created')</script>");
//Response.Write("Database Created");
}
else
{
Response.Write(
"File Name Not Found");
}
....................................................
Reply
Answers (
0
)
ASP.NEt View state
about jagged arrays in c#