Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 01, 2012 11:51 PM by mbanavige
0 Points
1 Post
Mar 01, 2012 11:07 PM|LINK
Apologies if this is a dumb question. I'm very new to .net
I'm using C# to try to send a query to SQL Server, and I'm using the following code:
<script runat="server"> System.Data.SqlClient.SqlConnection sqlconnection1 = new System.Data.SqlClient.SqlConnection("Data Source=;Initial Catalog=;User Id=;Password=;");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(); command.CommandType = System.Data.CommandType.Text command.CommandText = "INSERT STATEMENT">; command.Connection sqlconnection1;
sqlconnection1.Open(); cmd.ExecuteNonQuery(); sqlconnection1.Close();
</script>
I get "BC30188: Declaration expected."
I'm not sure what this error means. Can anyone advise?
All-Star
134962 Points
15421 Posts
ASPInsiders
Moderator
MVP
Mar 01, 2012 11:51 PM|LINK
I think the issue would be with whatever your actual sql insert statement was. So you'd needed to share that insert so we can see what it looked like.
cschaefer84
0 Points
1 Post
Declaration Expected when connecting to SQL Server
Mar 01, 2012 11:07 PM|LINK
Apologies if this is a dumb question. I'm very new to .net
I'm using C# to try to send a query to SQL Server, and I'm using the following code:
<script runat="server">
System.Data.SqlClient.SqlConnection sqlconnection1 =
new System.Data.SqlClient.SqlConnection("Data Source=;Initial Catalog=;User Id=;Password=;");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
command.CommandType = System.Data.CommandType.Text
command.CommandText = "INSERT STATEMENT">;
command.Connection sqlconnection1;
sqlconnection1.Open();
cmd.ExecuteNonQuery();
sqlconnection1.Close();
</script>
I get "BC30188: Declaration expected."
I'm not sure what this error means. Can anyone advise?
mbanavige
All-Star
134962 Points
15421 Posts
ASPInsiders
Moderator
MVP
Re: Declaration Expected when connecting to SQL Server
Mar 01, 2012 11:51 PM|LINK
I think the issue would be with whatever your actual sql insert statement was. So you'd needed to share that insert so we can see what it looked like.