hey all,
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
class Program
{
static void Main()
{
string queryString =
"SELECT CategoryID, CategoryName FROM dbo.Categories;";
using (SqlConnection connection = GetConnectionString())
{
SqlCommand command = connection.CreateCommand();
command.CommandText = queryString;
try
{
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine("\t{0}\t{1}",
reader[0], reader[1]);
}
reader.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
static private SqlConnection GetConnectionString()
{
SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder();
csb.DataSource = @"(local)\SQLEXPRESS";
//csb.IntegratedSecurity = true;
csb.InitialCatalog = "Northwind";
csb.ApplicationName = "MyDemoApp";
csb.UserID = "vbadmin";
csb.Password = "vbsa";
string connectionString = csb.ToString();
SqlConnection conn = new SqlConnection();
conn.ConnectionString = connectionString;
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = @"sp_setapprole";
SqlParameter parameter;
parameter = cmd.Parameters.Add("@rolename", SqlDbType.NVarChar, 128);
parameter.Value = "testRole";
parameter = cmd.Parameters.Add("@password", SqlDbType.NVarChar, 128);
parameter.Value = "test";
cmd.ExecuteNonQuery();
return conn;
}
}
can someone please show me what i'm doing wrong. i'm getting the following
error:
i'm not sure i have the setapprole in the right place or if it's a syntax
issue. kinda lost at this point.
thanks,
rodchar