My web service app on my Windows XP box is trying to log in to my sql server 2005 database on the same box. The machine is part of a domain. I am logged in in the domain and I am an admin on my machine. I am using Windows Authentication in my connection string as in "Server=myServerAddress;Database=myDataBase;Trusted_Connection=True". SQLServer is configured for both types of authentication (mixed mode) and accepts remote connections and accepts tcp and named pipes protocols. Integrated authentication is enabled in IIS and with and without anonymous access. 'Everyone' has access to computer from network setting in local security settings. ASPNET is a user in the sql server and has access to the daatabase. user is mapped to the login.
The app works fine for other developers which means the app shouldn't be changed (It's not new code). So it seems it's my machine which has an issue.
I am getting the error "Login failed for user ''. The user is not associated with a trusted SQL Server connection" Note the blank user name. Why am I getting this error when both the app and database are on my machine? I can use SQL Server authentication but don't want to. I can connect to the database using SSMS and my Windows credentials.
It might be related to setspn, kerberos, delegation, AD. I am not sure what further checks to make?
When I am in edit mode on any row of my GridView and I press Return while the focus is in one of the row's textboxes, instead of triggering the update button, my GridView1.RowEditing event is fired with a NewEditIndex of 0
This causes the first row to become editable and I lose any values typed into the previous row.
How can I stop this from happening?
Thanks
i have one default.xml file where i am storing all default values.suppose if invalid file with the same default.xml name exists i have to display message in the status bar.
i wrote a simple function in controller
public string LinkProjectSquareFilter(int squareId)
{
return squareId.ToString();
}
how can i call it from view? it say The name 'LinkProjectSquareFilter' does not exist in the current context
i have 3 div tags.Each having no. of textboxs and button.Each textbox having validation.For all button causesvalidation property is true.If i click "button1" in "div1" tag will cause validation of other textbox in other div tags.I dont want to do this ? How to avoid this?
Hi
i am trying to implement a generic method which allows to output csv file
public static void WriteToCsv<T>(List<T> list) where T : new()
{
const string attachment = "attachment; filename=PersonList.csv";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", attachment);
HttpContext.Current.Response.ContentType = "text/csv";
HttpContext.Current.Response.AddHeader("Pragma", "public");
bool isFirstRow = true;
foreach (T item in list)
{
//Get public properties
PropertyInfo[] propertyInfo = item.GetType().GetProperties();
while (isFirstRow)
{
WriteColumnName(propertyInfo);
isFirstRow = false;
}
Type type = typeof (T);
StringBuilder stringBuilder = new StringBuilder();
foreach (PropertyInfo info in propertyInfo)
{
//string value ???? I am trying to get the value of the property info for the item object
}
HttpContext.Current.Response.Write(stringBuilder.ToString());
HttpContext.Current.Response.Write(Environment.NewLine);
}
HttpContext.Current.Response.End();
}
but I am not able to get the value of the object's property
Any suggestion?
Thanks
Whatz wrong this MSSQl Query :
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SQLData As New System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True")
Dim cmdSelect As New System.Data.SqlClient.SqlCommand("SELECT COUNT(*) FROM Table1 WHERE Name ='" + TextBox1.Text + "'", SQLData)
SQLData.Open()
If cmdSelect.ExecuteScalar > 0 Then
Label1.Text = "You have already voted this service"
Return
End If
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.Open()
cmd.Connection = con
cmd.CommandText = "INSERT INTO Tabel1 (Name) VALUES('" & Trim(Label1.Text) & "')"
cmd.ExecuteNonQuery()
Label1.Text = "Thank You !"
SQLData.Close()
End Sub
var radiobox = document.getElementById('<%=rdoRiskAccepted.ClientID%>');
alert(radiobox[0].checked);
I am getting undefined as a alert. what am I doing wrong.
Is there a way to retrieving parameter names and values passed to a web method from Request object? I've read somewhere that you need extra code to access the soap body. Any known workarounds to be able to see the soap body from Application_BeginRequest?
Thanks!
I have 2 texboxes and 1 needs validation. I have this setup with Html.ValidationSummary display. I would like to keep the data that has been entered on the validation postback. Instead the page is refreshed and the data is lost which makes the user enter the data again. How do I prevent that without using sessions?
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SQLData As New System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True")
Dim cmdSelect As New System.Data.SqlClient.SqlCommand("SELECT COUNT(*) FROM Table1 WHERE Name =" + TextBox1.Text + " And Last = '" + TextBox2.Text + "'", SQLData)
SQLData.Open()
If cmdSelect.ExecuteScalar > 0 Then
Label1.Text = "Record Found ! " & TextBox1.Text & " " & TextBox2.Text
Return
End If
Label1.Text = "Record Not Found ! "
SQLData.Close()
End Sub
I write this code to find whether the record entered in textbox1 and textbox2 exists or not ..if record exist ..then in label1 the text would be RECORD FOUND else NO RECORD FOUND
ERROR :
**when i enter in textbox1 and textbox2 then on button click event it shows the error : Invalid column name ,,**
I need to print out the querystring value "?type=xxx" inside my .aspx-page, why doesn't this work:
<%= Request.QueryString("type") %>
While this does:
<%= Request.QueryString(0) %>
The first prints out nothing, the second one prints out the value as expected, but it isn't always the first value I want...
Any ideas?
I'm used to creating the UI, BLL, DAL by hand (some times I've used LINQ-to-SQL or SubSonic for the DAL). I've done several small projects using MVC since its release.
On these projects I've still continued to write a BLL and DAL by hand and then incorporate those into the MVC's models/controllers. I'm looking to optimize my time on projects this seems like overkill and a potential waste of time.
Question
Would it be acceptable to roll a DAL such as SubSonic and directly use it in the Models/Controllers of my MVC web app? Now the models & controllers would act as the BLL. I just see this as a major timesaver to not have to worry about another tier.
UPDATE:
I just wanted to add that my concern isn't really with the DAL (I frequently use SubSonic and NH) but rather focus on the BLL. Sorry for the confusion.
I have an automatic property
public bool HasToolkit { get; set; }
when i try to initialize it like this-
Tandem t = new Tandem(GearCount = 5);
It gives an error as below
The name 'GearCount' does not exist in the current context
Whats wrong here ?
Also if i do normal intantiation it works fine.
Tandem t = new Tandem();
I've found information about Editor and Detail templates based on object name (i.e. DateTime, MyCustomObject) for use with MVC system. I am just wondering if it was possible for creating templates for use when creating the items in a similar fashion, where the form used for Creating the items is going to be different than the Editing Screen.
I guess this may be a novice question ( Which I am :) ).
While redirecting user to custom error page, for e.g. 404, to tell that page wasn't found, the type of this redirect is 302.
<error statusCode="404" redirect="/Utility/Error404.aspx" />
<error statusCode="400" redirect="/Utility/Error404.aspx" />
Is it possible to make this redirect 301 through Web.config?
Thanks in advance to you all code maniacs.
I have a treeview in a user control. I need to run a javascript function with every synch postback to scroll the div it's in to the right position. I've got it working, but I think there has to be a "cleaner" way to do it. In the Page_Load function of the control, I have the following code. Is there a better way to do it?
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "key" + DateTime.Now.Ticks, "RestorePosition();", true);
We are interested in the communities opinions on commercial MVC controls ie Telerik, Syncfusion. Which is fast, easy to use, stability, documentation, support and all that good stuff.
We are about to start our second MVC project and are currently doing research into improving functionality and speed of development to 'standard' MVC.
Any of your thoughts are much appreciated...
I have very long select query which i need to filter based on some params, i'm trying to avoid having different stored procedures or if statements inside of single stored procedure by using partly dynamic TSQL...
I will avoid long select just for example sake
select a
from b
where c=@c
or d=@d
@c and @d are filter params, only one can filter at the same time but also both filters could be disabled. 0 for each of these means param is disables so i can create nvarchar with where statement in it...
How do i integrate in here dynamic query so 'where' can be added to normal query. I cannot add all the query as big nvarchar because there is too many things in it which will require changes ( ie. when's, subqueries, joins)
I am using a data grid and has bound a data source with it. I am trying to get the total number of records in the grid in overriden InitializePager method from pagedDataSource DataSourceCount. I thought DataSourceCount returns number of records from SelectCountMethod of ObjectDataSource. But DataSourceCount is giving me the page size and not the total number of records, whereas when I debug and see in SelectCountMethod it is returning correct number of total Records. I am not sure how to get the data from SelectCountMethod in DataGrid.
So I am working on a gridview that uses the order number to order the table.
However, my users are able to ad a row. What i want is something similar to pages that have the arrows next to each row and the user can click up if they want that row to go up. I also want it to change the actual number in the row column. for the one being moved and for the other one being affected. I hope i am being clear enough
I need to get the value of a property defined in a lambda
public static MvcHtmlString MyHelper<T, TProperty>(
this HtmlHelper<T> html,
Expression<Func<T, TProperty>> prop)
{
var value = \\ get the value of Prop1 (not the name "Prop1")
...
}
the intended usage is something like:
public class FooViewModel
{
public string Prop1 { get;set; }
}
<%@ Page ViewPage<FooViewModel> %>
<%=Html.MyHelper(o => o.Prop1) %>