Showing posts with label dbo. Show all posts
Showing posts with label dbo. Show all posts

Thursday, March 22, 2012

Access accessing SQL {}

Im using Access to access a SQL database. For one of the queries i see the following under column:

{ fn month(dbo.TableName.Date) }

Ive never used this structure before but im confused to what it is? Can anyone explain please?

Thanks

The curly braces and 'fn' server to denote a OBDC level function.

The T-SQL equilivent would be:

month( YourDateColumn )

|||

Hello

Thanks for that. Could you explain a bit more on that please? As far as im concerned i didnt think there would be an ODBC link as it was connecting straight to a SQL database (checking ODBC theres no link to a SQL database either). Maybe an example if you can on what this user could have been trying to achieve would be great?

Thanks

Thursday, February 9, 2012

About an error message " Could not find stored procedure dbo.U_Login ".

Hi All,I am having an error message when running the program below, the message says " Could not find stored procedure 'dbo.U_Login ". I have tried a inline Sql statement to match if user exists and then redirects to another page but when using a Stored Procedure what I get is the above mentioned error. I am logged onto my PC as Administrator but I don't know why this error appaears. Can anyone help me with this ? I am using SQL Server Express with Visual Studio. here the application I am trying to run:

1using System;2using System.Data.SqlClient;3using System.Data;4using System.Configuration;5using System.Web;6using System.Web.Security;7using System.Web.UI;8using System.Web.UI.WebControls;9using System.Web.UI.WebControls.WebParts;10using System.Web.UI.HtmlControls;111213public partialclass _Default : System.Web.UI.Page14{15protected void Page_Load(object sender, EventArgs e)16 {1718 }19protected void btnSubmit_Click(object sender, EventArgs e)20 {2122//SqlDataSource LoginDataSource = new SqlDataSource();23 //LoginDataSource.ConnectionString =24 // ConfigurationManager.ConnectionStrings["LoginConnectionString"].ConnectionString;25 ////ConfigurationManager.ConnectionStrings["LoginConnectionString"].ToString();26 ////// if (LoginDataSource != null)27 //// // Response.Redirect("DebugPage.aspx");2829 //Sql connection = LoginDataSource.ConnectionString;3031string UserName = txtUserName.Text;32string Password = txtPassword.Text;3334// string query = "SELECT * FROM Users WHERE userName = @.UserName " + "AND Password = @.Password";35 //SqlCommand Command = new SqlCommand(query, new SqlConnection(GetConnectionString()));3637 SqlCommand Command =new SqlCommand("dbo.U_Login",new SqlConnection(GetConnectionString()));383940//SqlConnection SqlConnection1 = new SqlConnection(GetConnectionString()); //added41 //SqlCommand Command = new SqlCommand(); //added42 //Command.Connection = SqlConnection1; //added43 // Command.Connection = new SqlConnection(GetConnectionString());44 //SqlConnection_1.Open();//added4546 Command.CommandType = CommandType.StoredProcedure;//added47 //Command.CommandText = "dbo.U_Login"; //added4849505152 Command.Parameters.AddWithValue("@.UserName", UserName);5354 Command.Parameters.AddWithValue("@.Password", Password);5556 Command.Connection.Open();5758 SqlDataReader reader;596061//reader = Command.ExecuteReader(CommandBehavior.CloseConnection);116263 reader = Command.ExecuteReader();646566if (reader.Read())6768 Response.Redirect("DebugPage.aspx");69else70 Response.Write("user doesn't exist");717273//SqlConnection_1.Close();//added747576 }77private static string GetConnectionString()78 {7980return ConfigurationManager.ConnectionStrings["LoginConnectionString"].ConnectionString;8182 }838485 }86878889

Thanks in advance

Hello my friend,

Try it without the "dbo." prefix in the code.

Kind regards

Scotty