Connecting To Sql2005 Using C#
Feb 12, 2006
Help... I am new to C# and .net and I am trying to build a insert page with a couple of drop down controls where I pull a categoryID and subcategoryID to populate my dropdown controls from a MS sql2005 express database. I am using a book that only shows how to build the script and access a access database and I am getting this error when trying to pull up the page:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'OleDbConnection' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 3:
Line 4: <script runat="server" language="C#">
Line 5: OleDbConnection objConn = newOleDbConnection(
Line 6: "Server=SIMBA\NETSDK;" +
Line 7: "Database=btuniverse;" +
Source File: c:Inetpubwwwroot\_addnews.aspx Line: 5
Below is my code and I am not sure what the syntax needs to be when connecting to a ms sql datasource. Thanks in advanced :)
MYCODE:
<%@ Page Language="C#" MasterPageFile="~/main.master" Title="Untitled Page" %>
<script runat="server" language="C#">
OleDbConnection objConn = newOleDbConnection(
"Server=SIMBA\NETSDK;" +
"Database=btuniverse;" +
"User ID=sa;Password=password");
OleDbCommand objCmd;
OleDbDataReader objRdr;
void Page_Load() {
if (!IsPostBack) {
objConn.Open();
objCmd = new OleDbCommand("SELECT * FROM dbo.tblNewsCategories", objConn);
objRdr = objCmd.ExecuteReader();
ddlCategory.DataSource = objRdr;
ddlCategory.DataValueField = "CategoryID";
ddlCategory.DataTextField = "CategoryName";
ddlCategory.DataBind();
objRdr.Close();
objCmd = new OleDbCommand("SELECT * FROM dbo.tblSubCategories", objConn);
objRdr = objCmd.Executereader();
ddlSubCategory.DataSource = objRdr;
ddlSubCategory.DataValueField = "SubCategoryID";
ddlSubCategory.DataTextField = "SubCategoryName";
ddlSubCategory.DataBind();
objRdr.Close();
objConn.Close();
}
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table>
<tr>
<td align="right">Title:</td>
<td align="left"><asp:TextBox ID="txtArticleTitle" CssClass="textbox" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtArticleTitle" ErrorMessage="*" runat="server" />
<br />
</td>
<!--- <asp:CompareValidator ID="cvArticleTitle" ControlToValidate="txtArticleTitle" Operator="DataTypeCheck" Type="String" ErrorMessage="No numbers allowed" />--->
</tr>
<tr>
<td align="right"><p>Article Category:</td><td align="left"><asp:DropDownList ID="ddlCategory" CssClass="dropdownmenu" runat="server" /></td>
</tr>
<tr>
<td align="right"><p>Article Sub Category:</td><td align="left"><asp:DropDownList ID="ddlSubCategory" runat="server" /></td>
</tr>
<tr><td align="right">News Article:</td><td align="left"><asp:TextBox ID="txtArticleDesc" CssClass="textbox" Columns="40" Rows="4" TextMode="MultiLine" runat="server" />
<asp:RequiredFieldValidator ID="rfvArticleDesc" ControlToValidate="txtArticleDesc" ErrorMessage="*" runat="server" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
<asp:Button ID="btnSubmit" CssClass="button" runat="server" Text="Submit" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>
View 3 Replies
ADVERTISEMENT
Jul 31, 2007
Hi,
I have 2 boxes, 1 webserver and 1 db server, both behind a firewall. For the past few years I have been connecting from the webserver to the db server using a public IP. I have 2 NIC's in the DB server so I now want to connect locally to reduce our companies bandwidth charges, and hopefully make things a tiny bit faster too. I'm not sure if it will make a difference, but should be interesting.
I'm having problems setting this up tho, what steps do I need to take to make sure it works properly?
When I check my DB servers IP configuration I get 2 NICs'
One configured as an external IP, the other configued as
169.xxx.xx.xxx
I am trying to connect using the 169.xxx.xx.xx Is this the correct approach? I am getting TimeOut Errors as seen below
I looked in my SQL configuration and its set to allow remote connections however, and since I was connecting over a public IP before, this seems contridicting.
Any help is much appreciated.
Thanks once again!!! :)
mike123
System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
View 3 Replies
View Related
Jan 16, 2007
Hi
I am trying to upgrade a system from SQL 2000 to SQL2005.
I have installed the Server on a PC with Win XP SP2. Using another PC (also Win XP SP2) on the LAN I need to ODBC to the Server.
The Server is NOT the default instance.
I cannot connect via ODBC from the Client PC. This all worked fine with SQL 2000.
As a test I also tried a fresh install of SQL2005 where it was the default instance, this worked fine.
SO the problem is when you have multiple instances.
What do I have to do to sort it out?
Cheers
Eugene
View 5 Replies
View Related
Jul 7, 2007
I'm trying to move an application I wrote from sql2000 to sql2005. The application is in ASP.NET and works fine using SQL2000 but when I moved the database and change the connect string the page display the message:
Cannot open database "EventTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITYANONYMOUS LOGON'.
If I add the identify tag to the web.config file
<identity impersonate="true" username="myname" password="mypasword"/>
then page comes up and everything works. The problem is I need to have the user's credentials from internet explorer to be used against the SQL database to control access.
I added some lines of code to see if the web page was acting with the web users credientials and it is for things other than the SQL2005 connections.
The following error message shows up in the web server's application log:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 7/6/2007 6:50:10 PM
Event time (UTC): 7/7/2007 12:50:10 AM
Event ID: c3d90a99419f49ad8d307930acb5bb71
Event sequence: 13
Event occurrence: 2
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/Root/ComputerServices/TruckerViewer-9-128282421386484375
Trust level: Full
Application Virtual Path: /ComputerServices/TruckerViewer
Application Path: c:inetpubwwwrootComputerServicesTruckerViewer
Machine name: webserver
Process information:
Process ID: 960
Process name: aspnet_wp.exe
Account name: webserverASPNET
Exception information:
Exception type: SqlException
Exception message: Cannot open database "EventTracker" requested by the login. The login failed.
Login failed for user 'NT AUTHORITYANONYMOUS LOGON'.
Request information:
Request URL: http://serverws/ComputerServices/TruckerViewer/Counters.aspx
Request path: /ComputerServices/TruckerViewer/Counters.aspx
User host address: 10.10.17.187
User: $PCAUser4
Is authenticated: True
Authentication Type: NTLM
Thread account name: webserverASPNET
Thread information:
Thread ID: 1
Thread account name: webserverASPNET
Is impersonating: False
Stack trace: at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at TruckerViewer.Counter1.Page_PreRender(Object sender, EventArgs e) in \webserverc$InetpubwwwrootComputerServicesTruckerViewerCounters.aspx.vb:line 61
at System.Web.UI.Control.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
The SQlserver's application log records two messages;
Login failed for user 'NT AUTHORITYANONYMOUS LOGON'. [CLIENT: 10.10.94.136]
and
Login succeeded for user 'NT AUTHORITYANONYMOUS LOGON'. Connection: trusted. [CLIENT: 10.10.94.136]
This exact same code works with SQL2000 but not with SQL2005. What am I missing? Any help would be appreciated.
View 5 Replies
View Related
Jan 30, 2006
I'm attempting to connect to and instance of SQL and cannot seam to find it. The server logs says its listening on '127.0.0.1 <ipx4> 1545'.
Kind of stuck what to check next. Will using pipes help? What do I need to do?
View 1 Replies
View Related
Sep 20, 2007
New sql2005 install as a named instance and having trouble connecting from remote machines.
I noticed on our other servers that the "Public" server role is listed in permissions (right-click over the sqlmgr connection for the dialog, then permissions).
When I try to add the role to the new server it doesn't save! This is the only setting that's different, can't connect using sqlmgr from other machines to this server so any ideas on other settings to look at appreciated.
View 6 Replies
View Related
Jan 22, 2008
OK, I'm stumped and could do with some help. I have a laptop running Vista (64bit) with the SQL 2005 client tools. At home, I have SQL Server 2000 running on Windows Server 2003. I cannot get the SQL 2005 to talk to the SQL Server 2000. At work, we have SQL 2000 running on NT 5.0 and it connects fine. I also have a second laptop with SQL 2000 client tools running on XP SP2 which conects fine to the SQL 2000 instance on the 2003 box.
The vista laptop talks to the 2003 server, so it's not simpy that there is no connection. Any ideas why I keep getting an error stating that the Server might not be accepting remote connections every time I try to connect the Vista machine to the SQL 2000 server? I can't connect either from the SQL management tool, nor via ODBC.
Any ideas would be much appreciated.
View 24 Replies
View Related
Dec 15, 2005
hi
i try to restore a bak file from another sql2005 server to my sql2005 server, but it show the error message as below :
TITLE: Microsoft SQL Server Management Studio Express
------------------------------
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)
------------------------------
ADDITIONAL INFORMATION:
Cannot open backup device 'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackupackup.bak'. Operating system error 5(error not found).
RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3201)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=3201&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
pls some one can help me ???
thanks
chaus
View 62 Replies
View Related
Oct 12, 2007
Can you open/use a database created in SQL2005 in SQL2005 Express?
Thanks for the help!
Max
View 4 Replies
View Related
Dec 27, 2005
I just upgraded my SQL 2000 server to SQL2005. I forked out all that money, and now it takes 4~5 seconds for a webpage to load. You can see for yourself. It's pathetic. When I ran SQL2000, i was getting instant results on any webpage. I can't find any tool to optimize the tables or databases. And when I used caused SQL Server to use 100% cpu and 500+MB of ram. I can't have this.Can anyone give me some tips as to why SQL 2005 is so slow?
View 3 Replies
View Related
Jan 4, 2007
Hi
We have Sql2005 x64 bit standard edition server installed in windows 2003 64 bit editio server,
currently due to buisness requirements we need to have sql2005 x64 bit enterprise edition, please let me know how do i do the upgrade or change.
is it possible to retain all our custom settings in the standard edition after changing to enterprise edition.
This has to be done for our production and very critical, please help
Thanks
Samuel I
View 4 Replies
View Related
Sep 19, 2007
I am unable to install 32-bit SQL Server Integration Services on the server due to something that was left behind by the 64-bit version.
I've uninstalled SQL Server 2005 64-bit and when I try to install the 32-bit version of Integration Services, I get this error: "Failed to install and configure assemblies C:Program Files (x86)Microsoft SQL Server90DTSTasksMicrosoft.SqlServer.MSMQTask.dll in the COM+ catalog. Error: -2146233087 Error message: Unknown error 0x80131501 Error descrition: FATAL: Could not find component 'Microsoft.SqlServer.Dts.Task.MessageQueueTask.ServCompMQTask' we just installed."
I can't seem to figure out how to resolve this problem with the COM+ and I can't remember if Integration Services is required.
Can anybody please advise?
View 1 Replies
View Related
Jul 8, 2007
Hello,
I have a vb program that include a dts package that has been saved to vb with sql2000 dts wizard and works very good.
Now that I upgrade my website to sql2005, this vb dts package doesn't work.
The error I get is:
Microsoft Data Transformation Services (DTS) Package
Invalid STDGMEDIUM structure
(Microsoft Data Transformation Services (DTS) Package (80040066): Invalid STDGMEDIUM structure
) (Microsoft SQL-DMO (ODBC SQLState: 42000) (80004005): [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'.)
I searched in the internet how to make dts package in sql2005 and save it to vb and found no information about it.
What Can I do to get the vb code of the dts package I create in sql2005 or how do i migrage the sql2000 vb dts package code to sql2005?
Thanks,
Kubyustus
View 4 Replies
View Related
Nov 13, 2006
I have some production boxes on Win 2000 32-bits OS and some production servers have been upgraded to Win2003 64-bit OS runing SQL Server 2005. There are also a number of Win2003 32-bit OS running SQL 2005.
The issue is that when linking the 64-bit production servers to the 32-bit boxes running SQL 2005 / Win 2003 OS, the linking seems to succeed, but I am unable to see a number of entries in sys.objects. Typically, these objects are User Stored Procedures.
Moreover, the linking seemed to have worked, but data extraction does not take place between the servers. However, there are no errors. The objects (user stored procs) exist on the 64-bit side, but linking does not actually happen.
Microsoft KB has addressed this in SQL 2000 case in this KB article, but has not suggested a solution for SQL 2005.
Any ideas? Has anyone else encountered this?
Thanks.
View 1 Replies
View Related
Dec 27, 2007
when iam trying to open a table in sqlserver 2005 it is showing an error as
SELECT permission denied on object 'LoginDetails', database 'LOGIN', schema 'dbo'.
how to rectify the error.
plz help me.
Thnaks in advance.
View 1 Replies
View Related
Jun 5, 2008
Dear all,
Is it possible to say sql server 2005 to use this much number of CPU..?
For Example I have 1 CPU License of SQL 2005, but I have 2 sockets in my physical box. One socket is having 2 cores. So I want to say the SQL server (2005) to use the 2 cpu's only( i.e Any of one socket)
Please advise me to do this.
I have one more question,
Is there any CPU limitation for SQL 2005 and 2008? If Yes how much cpu we can allot for the SQL 2005 and 2008
Thanks
Lakshmi.S
View 2 Replies
View Related
May 25, 2007
Hi All,
Can you send a SMS (text message to a cell phone) from stored proc?
Can it be done in SQL Server 2005?
Thanks
Live Today as if tomorrow is a DAY away :) - SuperGreen
View 2 Replies
View Related
Apr 9, 2007
On the MSDN site, I noticed new releases of SQL 2005, SP-2, dated on 4/5/2007. Are these an actual "update" to original release of SP-2?
View 1 Replies
View Related
Oct 8, 2007
I am installing sql2005 sp1 on a w2k3 Cluster. All we need is the database engine however the vendor I am working with said to install sp1 which is fine but they also said you need to install Integration services with SP1 for the Maintenenace plans.
Do I need to install Integration services on the cluster to create maintenance plans with sql2005 sp1 ??
I am getting mixed answers.
View 1 Replies
View Related
Sep 7, 2006
I hope you would help me in this problem. I use the code below for executenonquery command for mdb DB.But I do not know the changes I should made when Using SQL2005.-------------Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _ "Data Source=C:ASPNET20dataNorthwind.mdb" Dim dbConnection As New OleDbConnection(connectionString) dbConnection.Open() Dim commandString As String = "INSERT INTO Employees(FirstName, LastName) " & _ "Values(@FirstName, @LastName)" Dim dbCommand As New OleDbCommand(commandString, dbConnection) Dim firstNameParam As New OleDbParameter("@FirstName", OleDbType.VarChar, 10) firstNameParam.Value = txtFirstName.Text dbCommand.Parameters.Add(firstNameParam) Dim lastNameParam As New OleDbParameter("@LastName", OleDbType.VarChar, 20) LastNameParam.Value = txtLastName.Text dbCommand.Parameters.Add(LastNameParam) dbCommand.ExecuteNonQuery() dbConnection.Close()--------
View 2 Replies
View Related
Dec 31, 2005
What is the quivalent of EM for SQLExpress2005? With the old SQL 2000 I used EM to manage tables, SPs and such. Now, I cannot even find the databases - I installed the Club Starter Kit and I want to view and modify some tables. How do I do that?
View 3 Replies
View Related
Jan 19, 2006
Hi folks,
i have VSTS installed and TFS beta refresh 3. all is working fine.
How can i use Visual Studio 2005 to create a new database on the remote server? i can connecto to it fine using the 'server explorer' tab .. but of course it only lists databases that currently exist. How can i create a new one?
lastly, i have no installed sql2005 express edition or whatever it is called LOCALLY on my machine. the reason i didn't do this is becuase i was hoping to use the enterprise sql 2005 server.
View 4 Replies
View Related
Jun 13, 2006
Hi,
Just wondering if some one can help me out here I know that we can work with access2003 as a front end and SQL2000 as a back end. What I am trying to do now is working with SQL2005 as a back end I was wondering if it can be done ( I can access it but having errors creating tables etc).
Thanks
Sorry I was not sure where exactly to post this topic as it relates to both dbs so I have posted this same thread in Access as well.
View 2 Replies
View Related
Sep 22, 2006
I'm not "cobol person" but now, I have to bind a cobol application (from mainframe) to query SQL 2005
Have somebody had this task?
View 4 Replies
View Related
Feb 22, 2008
I have an SQL2005 db residing on a 64bit server.I can load and run my App, provided it is installed on the server.However when I try to run from a Client's PC I get timeout errors.
Initially the error was Remote connections not allowed,but I have overcome this by ensuring SQLbrowser was running and that AllClient and Server Prodtocols were enabled.
I now keep getting a message the timeout has expired.
Do I need to do more in a 64bit environment.
Please help !
View 1 Replies
View Related
Jun 5, 2008
hi
Did someone have the answer for this problem of SQL2005?
Event filter with query "select * from __InstanceModificationEvent within 10 where TargetInstance isa 'Win32_Service'" could not be (re)activated in namespace "//./root/Microsoft/SqlServer/ComputerManagement" because of error 0x80041010. Events may not be delivered through this filter until the problem is corrected.
View 4 Replies
View Related
Oct 16, 2006
What solutions are available?
Is there a way to read about from server's metadata?
Gus
View 1 Replies
View Related
Jun 1, 2007
Hi All.
I have SQL2000 on my WinXP computer. Can I install SQL2005 on my desktop? If yes what version?
Thanks.
View 1 Replies
View Related
Jun 26, 2007
Hi all,
I perform a export using sql2005 wizard to output the data from a table to a execl file and at the same time create a package.
The following error encounterd,anyone know what is the possible causes:
Operation stopped...
- Initializing Data Flow Task (Success)
- Initializing Connections (Success)
- Setting SQL Command (Success)
- Setting Source Connection (Success)
- Setting Destination Connection (Success)
- Validating (Success)
- Saving (Success)
- Prepare for Execute (Stopped)
- Pre-execute (Stopped)
- Executing (Error)
Messages
* Error 0xc001000e: New_test_export: The connection "DestinationConnectionOLEDB" is not found. This error is thrown by Connections collection when the specific connection element is not found.
(SQL Server Import and Export Wizard)
* Error 0xc001000e: New_test_export: The connection "DestinationConnectionOLEDB" is not found. This error is thrown by Connections collection when the specific connection element is not found.
(SQL Server Import and Export Wizard)
* Error 0xc00291eb: Drop table(s) SQL Task: Connection manager "DestinationConnectionOLEDB" does not exist.
(SQL Server Import and Export Wizard)
* Error 0xc0024107: Drop table(s) SQL Task: There were errors during task validation.
(SQL Server Import and Export Wizard)
- Copying to `COST_CENTER_V` (Stopped)
- Post-execute (Stopped)
- Cleanup (Stopped)
Thanks for help.
View 6 Replies
View Related
Jul 9, 2007
is there a way to import/export diagrams in sql 2005?
thnaks i nadvance
peleg
Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
View 1 Replies
View Related
Jul 17, 2007
hi, on the MS site it states :
For Workgroup and Standard, each virtual or physical operating environment containing a running instance of SQL Server requires a Server license.
Does this mean if I have 1 server running 6 instances I would require 6 SQL Server licenses ?
thank you ,
jamie
View 3 Replies
View Related
Jul 22, 2007
Hi all,
I just wonder can we install both sql2000 & sql2005
into one server, any problems?
thanks for advice.
View 1 Replies
View Related
Aug 4, 2007
Hi
I have 2 computers
DESKTOP : runs WinXP and SQL Server 2005
NOTEBOOK : runs Windows Vista and SQL Server 2005
when i try to connect to DESKTOP from NOTEBOOK i get this error
TITLE: Connect to Server
------------------------------
Cannot connect to DESKTOP.
------------------------------
ADDITIONAL INFORMATION:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=233&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
can anyone help me to fix it?!
View 3 Replies
View Related