I have a datasource on my ASP.NET 2.0 control I want to make dynamic. I have 6 different connection strings in my web.config file and want to change the connection with the selection in dropdownbox. Here is my VB code:Protected Sub GetDatabase(ByVal intDb As Integer) Select Case intDb
Case 1 ' Americas srcCustomers.ConnectionString = "RWSqlServer" Exit Sub Case 2 ' Asia srcCustomers.ConnectionString = "SGSqlServer" Exit Sub Case 3 ' Australia srcCustomers.ConnectionString = "SYSqlServer" Exit Sub Case 4 ' Canada srcCustomers.ConnectionString = "MSSqlServer" Exit Sub Case 5 ' EMEA srcCustomers.ConnectionString = "NCSqlServer" Exit Sub Case 6 ' NE srcCustomers.ConnectionString = "RUSqlServer" Exit Sub End Select End SubProtected Sub ddlBusinessUnit_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
If (ddlBusinessUnit.SelectedIndex = 0) Then panUser.Visible = False panDistributor.Visible = False panEndUser.Visible = False GetDatabase(ddlBusinessUnit.SelectedIndex) lblDb.Text = ddlBusinessUnit.SelectedIndex.ToString Else
panUser.Visible = True End If End Sub Here is my ASP.NET code:<asp:SqlDataSource ID="srcCustomers" runat="server" SelectCommand="SELECT cm_addr + ' - ' + cm_sort AS [name], cm_addr, cm_sort FROM cm_mstr WHERE cm_type <> 'I'"> </asp:SqlDataSource><asp:DropDownList ID="ddlBusinessUnit" runat="server"AutoPostBack="True" OnSelectedIndexChanged="ddlBusinessUnit_SelectedIndexChanged"> <asp:ListItem Value="" Text="Select One"></asp:ListItem> <asp:ListItem Value="1" Text="Americas"></asp:ListItem> <asp:ListItem Value="2" Text="Asia"></asp:ListItem> <asp:ListItem Value="3" Text="Australia"></asp:ListItem> <asp:ListItem Value="4" Text="Canada"></asp:ListItem> <asp:ListItem Value="5" Text="EMEA"></asp:ListItem><asp:ListItem Value="6" Text="NE"></asp:ListItem> </asp:DropDownList> What am I missing? Do I need to reference the whole connection string or is there a way I can reference the "NAME" id in the web.config file for the connection string?
Hi, I have created a .net class library and i include the namespace : using System.Data.SqlServer but when i build my .net class library i get the folowing error: The type or namespace name 'SqlServer' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
After I learned the XML Schemas Collection, Using XML Data and 5 XML data type methods : query(), valuse(), exist(), modify(), and node(), I just started to do XQuery by using the Microsoft XQuery Language Reference - SQL Server 2012 Books Online and Handling Namespaces in XQuery of [URL]. I copied the following code:
-- Handlimng Namespace in Xquery (Page 6 of XQuery Languge Reference & Examples of msdn library)
-- Example A. Declaring a namespace
-- saved as MicrosoftXQueryPage6 in C:DocumentsXquery-SQLServer2012
-- 4 Aug 2015 10:55 AM
SELECT Instructions.query(' declare namespace AWMI="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"; /AWMI:root/AWMI:Location[1]/AWMI:step ') as Result FROM Production.ProductModel WHERE ProductModelID=7
I executed the code in my Microsoft SQL Server 2012 Management Studio (SSMS2012). It worked nicely.
<AWMI:step xmlns:AWMI="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions"> Insert <AWMI:material>aluminum sheet MS-2341</AWMI:material> into the <AWMI:tool>T-85A framing tool</AWMI:tool>. </AWMI:step> <AWMI:step xmlns:AWMI="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions">
[code]....
But, I don't know what AWMI means and what the results of SELECT Instructions.query(' declare namespace...  are.Â
How can i assign select statement to a sqldatasource I mean if the user clicks button 1 sqldatasource=-"select * from customers where status='ClOSED' " or else if the user clicks button2 sqldatasource="Select * from Customers Where Status='OPEN' " I want to bind the sqldatasource to a gridview finally . Is this possible ? I tried sqldatasource filters But am reallly confused Any suggestions/solutions are appreciated thankyou
Hi Using ASP.NET 2.0, Sql Server 2005. I have a simple page (NOT a formview) with some entries textbox's , checkbox and dropdownlistbox's I want to link a datasource to the 'Item Page' and bind the datasource's values to the page The select statement is Select a.IssueID, a.ProjectID, a.VersionID, a.toincludeversionid, a.Version, a.toincludeversion, a.TypeofEntryID, a.PriorityID, a.WorkFlowID, a.Title, a.Area, a.Details, a.Question, a.Answer, a.HowToRepro, a.DevelopersNotes, a.TestersNotes, b.ProjectID, b.ProjectName, OldVersion.Version, ToIncludeVersion.Version, d.DESCRIPTION, e.DESCRIPTION,
x.TaskID as TaskID, x.DESCRIPTION as TaskDescription, z.Taskdone, CONVERT (char(9),z.TaskAssignedDate, 3) AS Workflowdate, z.StaffID as StaffID, w.username, y.latest_workflowid from issue as a Inner join ProjS b on b.ProjectId=a.ProjectID Left Outer join Version OldVersion on a.VersionID=OldVersion.VersionID Left Outer join Version ToIncludeVersion on a.VersionID= ToIncludeVersion.VersionID Inner join TypeOfEntry d on d.TypeOfEntryID=a.TypeofEntryID Inner join Priority e on e.PriorityID=a.PriorityID
inner join workflow z on z.issueid=a.issueid Inner join (select issueid,max(workflowid) as latest_workflowid from workflow group by issueid) y on y.latest_workflowid=z.workflowid Inner join task x on x.taskid=z.taskid Inner join staffls w on w.StaffID=z.StaffID
Where a.IssueID= @IssueID
I hope I have made query clear, if not I don't mind explaining more.
What different are there between connectionString (Part 1) and connectionString (Part 2) in web.config The CCWW is my PC's name, normally I can connect to the database ASPNETDB.MDF correctly either Part 1 or Part 2 in a web page,After I open Database Explorer panel and browse ASPNETDB.MDF, I can't connect to database using Part 2 when I open a webpage in Microsoft Visual Web Developer 2005 Express Edition,but I can correctly open a webpage using Part 1 after I open Database Explorer panel. What different are there between connectionString (Part 1) and connectionString (Part 2) in web.config? I guess while I use Part 1 to connect, maybe it will be cancel exclusive method of the database ASPNETDB.MDF first, but when I connect to database using Part 2, maybe two programms both Part 2 and Database Explorer visit ASPNETDB.MDF at the same time!
I'm trying to write my first sql server compact edition program. When I try to add a SqlCeConnection object to my .cs file, I need to add the namespace "using" reference. the online docs say it's System.Data.SqlServerCe, but my IDE won't find it. I've tried adding the reference, but neither System.Data.SqlServerCe nor system.data.sqlserverce.dll is on the .NET list. Where do I go from here?
I am trying to build a SQL Server 2000 (sp3) admin app in VB.NET that gives the users targeted access to EM functions without having to search through EM. At any rate, I cannot seem to re-initialize the SQL namespace, even after setting it to nothing (I want to enable a user to do work with one server, pop into another, etc). Here is a sample of what I am doing, stripped to its essentials. This code fails with the error in the subject line. Thanks in advance.
I'm trying to use WMI query to fetch events from alter_table class of SQL 2005, but the WMI script is reporting an error 0x80070005 while executing query "Select * from Alter_Table". The Connection to the namespace is successfull.
I've tried all Security settings via "CoSetProxyBlanket" but without success. Can anybody help me sort out this issue.
I recently restored an entire database hosted on a remote server onto my local PC. These are tables I created for an ASP.NET project I'm working on. Unfortunately, the tables are restored with a different namespace (I think that's what it's called).
So, dbo.Authors restored as dbo19738468.Authors. The 19738468 is the customer number that was assigned to me by my Web host, where I backed up the data I restored. Is there anyway to rename the dbo19738468 to simply dbo?
Hi all, I tried to do the Linq sample program, Already i have added System.Query namespace. But I am getting some errorlike No reference to System.Query. In my system , i have installed VS 2005 and .Net Framework 3.0. Apart from the this, please tell me , whether any software are required Regards and ThanksThirumurugan
I can't find the ReportingService's namespace... i see ReportingService inerhits from System.Web.Services.Protocols.SoapHttpClientProtoco but any code what i found its impossible to compile, i need the namespace...
I have a table like this : dbo.Table, and I recently create a namespace, and that table belongs there. So I want the table to be created on the new namespace, Namespace.Table, which is not big deal because I can script the table as a Create, and changes the [dbo].[table] to [Namespace].[Table]. But I need to import all the rows already on the old table. How can I achieve that? Thanks
public static DataReader GetPhotoById(int pPhotoId) { return MyFile.Providers.SqlFileProvider.Instance.PhotoGetById(pPhotoId); }That code is throwing me up the following error : Error 1 The type or namespace name 'DataReader' could not be found (are you missing a using directive or an assembly reference?) D:wwwWebSite1App_CodePhotoManager.cs 18 19 D:wwwWebSite1I'm pretty stuck to whats wrong? Any suggestions?Sorry, i'm really new to all this framework (and even this website);Dougal
using Microsoft.DataTransformationServices.Tasks.DTSProcessingTask; I get the following message:
Namespacename "Microsoft.DataTransformationServices.Tasks.DTSProcessingTask" not found. (Original in german: Fehler 6 Der Typ- oder Namespacename DataTransformationServices ist im Namespace Microsoft nicht vorhanden. (Fehlt ein Assemblyverweis?) )
I have now to include a reference on it, but I can´t find the file, belonging to this namespace. Somebody knows, where this namespace is included, or where can I find it?
In my DAL:using System;using System.Collections;using System.Data;using System.Data.SqlClient;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public DataReader getPersonList2() { using (SqlConnection conn = getConnection()) { SqlCommand cmd = new SqlCommand("PERSON_SP_getPersonList", conn); cmd.CommandType = CommandType.StoredProcedure; conn.Open(); return cmd.ExecuteReader(); } }In my BLL:using System;using System.Collections;using System.Data;using System.Data.SqlClient;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;DAL d = new DAL();public DataReader getPersonList2(){ return d.getPersonList2(); }I get the following error in my BLL: Compiler Error Message: CS0246: The type or namespace name 'DataReader' could not be found (are you missing a using directive or an assembly reference?) Source Error:
Line 34: }Line 35: Line 36: public DataReader getPersonList2(){Line 37: return d.getPersonList2();Line 38: }
Source File: c:InetpubwwwrootstudyApp_CodeBLL.cs Line: 36 Just wondering if someone could tell me why this is happening? I have the same namespaces that I have in the DAL in my BLL.Puzzled.
It states pretty clearly in the documentation for the Microsoft.SqlServer.Dts.Runtime.Wrapper namespace that "This assembly is a Primary Interop Assembly (PIA) for the namespace Microsoft.SqlServer.Dts.Runtime, which is the assembly Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll). The classes in this namespace should not be instantiated. Instead, use the classes found in the Microsoft.SqlServer.Dts.Runtime. "
And yet as I have found out earlier today and talked about here, sometimes it is absolutely necassary to use Microsoft.SqlServer.Dts.Runtime.Wrapper. Why is this? Why is there no class in Microsoft.SqlServer.Dts.Runtime that allows me to access the specific connection managers rather than using the generic ConnectionManager class?
I'm installing SQL Server Express SP1 on a new Windows XP Pro SP2 laptop that is part of a corporate network. The last item in the Setup Progress dialog box says:
Workstation Components, Books Online and Development Tools....Setup failed. Refer to log file.
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGSummary.txt looks fine except for the last few lines:
-------------------------------------------------------------------------------- Machine : ROVER Product : Microsoft SQL Server 2005 Tools Product Version : 9.1.2047.00 Install : Failed Log File : c:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_ROVER_Tools.log Last Action : InstallFinalize Error String : SQL Server Setup failed to modify security permissions on WMI namespace \. ootMicrosoftSqlServerComputerManagement. To proceed, verify that the account and domain running SQL Server Setup exist, that the account running SQL Server Setup has administrator privileges, and that the WMI namespace exists on the destination drive. Error Number : 29516
Is this a common error when installing on a PC that is part of a corporate network? I didn't dig too far into SQLSetup0004_ROVER_Tools.log; however, it contains a few references to "SOFTWARE RESTRICTION POLICY".
Other than this error, SQL Server Express seems to be working ok. Is this anything to be concerned about?
I created a clr proc that gets the most recent file within a directory based on the creation time property, see code below. I have attempted to replicate this within a clr scalar valued function in order to assign the resulting value to a variable within SQL server. I am getting the error message:
Msg 6522, Level 16, State 2, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate "clr_fn_recentfile":
System.InvalidOperationException: Data access is not allowed in this context. Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method.
System.InvalidOperationException:
at System.Data.SqlServer.Internal.ClrLevelContext.CheckSqlAccessReturnCode(SqlAccessApiReturnCode eRc)
at System.Data.SqlServer.Internal.ClrLevelContext.GetCurrentContext(SmiEventSink sink, Boolean throwIfNotASqlClrThread, Boolean fAllowImpersonation)
at Microsoft.SqlServer.Server.InProcLink.GetCurrentContext(SmiEventSink eventSink)
at Microsoft.SqlServer.Server.SmiContextFactory.GetCurrentContext()
at Microsoft.SqlServer.Server.SqlContext.get_CurrentContext()
at Microsoft.SqlServer.Server.SqlContext.get_Pipe()
at clr_fn_recentfile.clr_fn_recentfile.clr_fn_recentfile(SqlString Filepath)
After trying to troubleshoot this I am aware that this error is rather generic and have not been able to find any specific documenation regardint the use of file system objects with clr functions. I am at a loss. Any help would be appreciated! STORED PROC CODE WORKS
_ Public Shared Sub clr_recentfile(ByVal Filepath As SqlString) Dim strFile As String Dim sp As SqlPipe = SqlContext.Pipe() Dim maxDate As Date Dim fil As String Dim qry As New SqlCommand() Try If Directory.Exists(Filepath.ToString) Then
For Each strFile In Directory.GetFiles(Filepath.ToString) Path.GetFileName(strFile) fil = Path.GetFileName(strFile).ToString Dim fi As New FileInfo(strFile) If maxDate = Nothing Then maxDate = fi.CreationTime fil = fi.FullName.ToString Else If maxDate < fi.CreationTime Then maxDate = fi.CreationTime End If End If
Next Else sp.Send("Directory does not exist") Return End If If fil <> Nothing Then qry.CommandText = " SELECT '" & fil & "'" 'Execute the query and pass the result set back to SQL sp.ExecuteAndSend(qry) sp.Send(qry.CommandText.ToString) End If Catch ex As Exception sp.Send(ex.Message.ToString) End Try End Sub End Class
Partial Public Class clr_fn_recentfile <Microsoft.SqlServer.Server.SqlFunction()> _ Public Shared Function clr_fn_recentfile(ByVal Filepath As SqlString) As SqlString Dim strFile As String Dim sp As SqlPipe = SqlContext.Pipe() Dim maxDate As Date Dim fil As String Dim qry As New SqlCommand() Try If Directory.Exists(Filepath.ToString) Then
For Each strFile In Directory.GetFiles(Filepath.ToString) Path.GetFileName(strFile) fil = Path.GetFileName(strFile).ToString Dim fi As New FileInfo(strFile) If maxDate = Nothing Then maxDate = fi.CreationTime fil = fi.FullName.ToString Else If maxDate < fi.CreationTime Then maxDate = fi.CreationTime End If End If
Next Else sp.Send("Directory does not exist") Exit Function End If If fil <> Nothing Then Return fil End If Catch ex As Exception sp.Send(ex.Message.ToString) End Try
which is to parse a create table script using Microsoft.SqlServer.TransactSql.ScriptDom namespace..I get a list of statements : StatementList SQLStatement = parser.ParseStatementList(StreamReader, out errors);then I cast a relevant statement to the CreateTableStatement type which gives me access to the ColumnDefinition class.
foreach (TSqlStatement T in SQLStatement.Statements) { if (T is CreateTableStatement) { CreateTableStatement  TC= (CreateTableStatement)T}} with foreach (ColumnDefinition CD in TC.Definition.ColumnDefinitions)
I am ready to loop through the columns so far so good. I can get to the column name using CD.ColumnIdetifier.Value, to the data type using CD.DataType.Name.BaseIdentifier.Value, but can't seem to get to the length definition. Meaning, I can get column1 , varchar; but I need column1, varchar(40). where do I get (40) from?I tried using ScriptTokenStream under C.DataType, but it seems to iterate through all tokens not just ones relevant to that fragment.
Where can I find the reference to Microsoft.SqlServer.Management.Smo in SQL Server 2005?
I currently have Microsoft SQL Server 2005, Microsoft SQL Native Client and Server VSS writer installed. (and ran the Service Pack 2 installer, but it doesn't want to update 'Database Services')
I am using Custom Security Extension DLL for implementing Forms Authentication in Reporting Service 2005. While Login I am getting an "Invalid Namespace" error. After debugging it, i found below lines in the AuthenticationUtilities.cs page of the Custom DLL which is giving error.
I have an XML file that some of the nodes are represented with a namespace prefix. I have found the "msdn" page where shows the possibility to filter using the Namespace Prefix, but I have not been successful at it.
Hello,I just lost all my data doing a system restore and now trying to rebuild my web project.However, Am getting the error below, trying to use a class to run my Stored procedure.What is wrong herethanksEhiCompiler Error Message: CS0246: The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?)Source Error:Line 22: //SqlConnection con = new SqlConnection("cellulant_ConnectionString"); Line 23: //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cellulant_ConnectionString"].ToString()); Line 24: SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["cellulant_ConnectionString"].ToString()); Line 25: Line 26: Source File: c:inetpubwwwrootcellulant1App_Codesignup_data-entry.cs Line: 24 using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;
public class signup_data_entry { public signup_data_entry(DateTime dob1) {
//SqlConnection con = new SqlConnection("cellulant_ConnectionString"); //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cellulant_ConnectionString"].ToString()); SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["cellulant_ConnectionString"].ToString());
SqlCommand command = new SqlCommand("Cellulant_Users_registration", con); command.CommandType = CommandType.StoredProcedure;
I have been using the ServiceBrokerInterface example for a project of mine and so far it has been very successfull. However , I recently attempted to use it to send a large-ish message (32K xml file from MS Word) to SQL. The message is recieved but the Body member of the message is null when I try to retrieve the data from within my stored procedure CLR method.
The only differences I can see between the message that does not work and those that do are that the one that doesn't is large and it is XML data that I read from a .xml file produced by MS Word as opposed to internally generated strings in the other working messages.
Does anybody have any suggestions as to why the body of the message is not being sent in this case? Is there something about the example code that precludes sending this type of message?
This is the code that sends the message (extracted from Conversation.cs in ServiceBrokerExample)
Just installed Express edition on my laptop and don't know how to set up the connection string in my aspx.vb page. I've added my connection in the webconfig page and want to set up the vb page. This is not working please tell me what's missing in the Dim conn section.Protected Sub SubmitInfo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitInfo.Click Dim conn As ConnectionStringsSection = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|BEEN.mdf;Integrated Security=True;User Instance=True"Dim cmd As New Data.SqlClient.SqlCommandWith cmd .Connection = conn .CommandType = "AddUserInfo".Parameters.AddWithValue("@FName", Fname.Text) .Parameters.AddWithValue("@LName", LName.Text).Parameters.AddWithValue("@Email", Email.Text) .Parameters.AddWithValue("@Comments", Comments.Text) End With conn.Open() cmd.ExecuteNonQuery() conn.Dispose() End Sub
Hi I'm using Sql Server (SQLOLEDB.1) and I want to connect it by Sqlconnection.those are the details:user Id: saPassword: *****database: ServiceManagementserver name: KLXPE002KULMOSWhat should be the Connection String? Thats what i did: "Persist Security Info=True;Integrated Security=SSPI;server=SQLOLEDB.1;database=ServiceManagement;Data Source=KLXPE002KULMOS;User ID=sa;password=****"It doesn't work.thnxItai
Hello, I have just tried to deploy my app from my local pc to our server and I have been getting this error. Server Error in '/' Application.
Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.Source Error:
Line 164: <providers> Line 165: <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" Line 166: type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> Line 167: <add name="AspNetWindowsTokenRoleProvider" applicationName="/" Line 168: type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />Source File: C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Configmachine.config Line: 166
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42 I am new to SQLExpress 2005 and asp.net 2.0. I created some database files on my local pc then copied the whole app to the server. Not sure what to do. Any help would be greatly appreciated or direction to info. Thanks Matt