Programmaticaly Connecting And Accessing A Database
Apr 25, 2007
I have not been able to find a code example anywhere. Someone please post the code to do this. I would be forever grateful.
I would like the code to be in C#. I want to connect to a database and then select all from a table.
thanks
View 12 Replies
ADVERTISEMENT
Jun 6, 2006
Hi All,I have an SqlDataSource on my page which queries a MySql Db.I am trying to use this for a login page but it only works for the first row of the Db.I can kinda see where it's going wrong, by the password(0) bit becuase it is only looking at the first row, correct?How can I get it to look at all the rows in the Db so anyone in the Db can login?Thanks in Advance,GProtected Sub btnLogin1_Click(ByVal sender As Object, ByVal e As EventArgs) 'Dim adapter As New OleDbDataAdapter(cmd, MyConn) Dim password As DataView Dim arg As New DataSourceSelectArguments password = SqlDataSource1.Select(arg) If password(0)("username1") = txtName.Text Then If password(0)("password1") = txtPass.Text Then Session("BlnLoggedIn") = True Response.Redirect("Default.aspx") If password(0)("admin1") = "1" Then Session("admin") = True Else Session("admin") = False End If End If End If End Sub
View 9 Replies
View Related
Jan 3, 2008
Hi All SSIS experts,
Happy 2008!!!!
I am inserting data into a tab delimted text file using SSIS package.
After data insetion some extra tabs get added between columns in some rows in the text file.
Can we programmatically delete the extra tabs from the text file, if so how to use/implement the code inside the SSIS package?
Any pointer/suggestions are welcome.
Thanks & Regards,
View 9 Replies
View Related
Apr 15, 2008
Hi,
In a stored procedure is there a way of accessing a table presend in another database.
Please provide pointers on how i can do this.
Thanks,
Raj
View 4 Replies
View Related
May 25, 2007
Hello,
I just switched to a host that allows database connections so that I can now upload my database to their server.
When I test my site on my personal PC it works great. I upload everything to the server and nothing. I know that I need to load the database to the server. I have Microsoft SQL Server 2005 Express and can make the connection but how do i load my database from my personal PC to the host computer?
I would be greatful if someone was able to walk me thou the steps on how to transfer the database. I am really very new with the database thing and ASP.
Thank You
Chris
View 1 Replies
View Related
Jan 22, 2007
Hello Everyone,
Is it possible to write a query that can access data in differnt database so I have "trainee" and "training" databases. In want to access one training table in trainee database through a query. How can I do this.
Thanks.
View 1 Replies
View Related
Feb 8, 2007
Hi,
I would like to know if there is any way of Accessing database users from frontend and changing their persmissions.
Thanks
Niranjana.
View 10 Replies
View Related
Aug 30, 2007
Hay there,I have an asp.net project website with an sql Database. I need to access this same database from another project (a class library that needs to access this database). In fact i want to be able to use the tableadapters that I have implemented for my database in this new class library.. I guess it has to do something with making my database not part of the website but and independemt entitiy that can be seen by others..... I cannot seem to find a way to do that can anyone help meee ????Thanks for your time!
View 6 Replies
View Related
Oct 24, 2007
Hello friends when I am working in VWD and accessing sql data this error came?I am using asp.net visual web developer edition and sql server 2005 expressedition. plz check it out and help me.The log scan number (588:85:1) passed to log scan in database
'D:GCAPAPP_DATAGRIET_IT.MDF' is not valid. This error may indicate data
corruption or that the log file (.ldf) does not match the data file (.mdf). If
this error occurred during replication, re-create the publication. Otherwise,
restore from backup if the problem results in a failure during startup.
Could not open new database 'D:GCAPAPP_DATAGRIET_IT.MDF'. CREATE DATABASE
is aborted.An attempt to attach an auto-named database for file
D:GCAPApp_DataGRIET_IT.mdf failed. A database with the same name exists, or
specified file cannot be opened, or it is located on UNC share.
Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code. Exception Details:
System.Data.SqlClient.SqlException: The log scan number (588:85:1) passed to
log scan in database 'D:GCAPAPP_DATAGRIET_IT.MDF' is not valid. This error
may indicate data corruption or that the log file (.ldf) does not match the data
file (.mdf). If this error occurred during replication, re-create the
publication. Otherwise, restore from backup if the problem results in a failure
during startup. Could not open new database 'D:GCAPAPP_DATAGRIET_IT.MDF'.
CREATE DATABASE is aborted.An attempt to attach an auto-named database for
file D:GCAPApp_DataGRIET_IT.mdf failed. A database with the same name exists,
or specified file cannot be opened, or it is located on UNC
share.Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): The log scan number (588:85:1) passed to log scan in database 'D:GCAPAPP_DATAGRIET_IT.MDF' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup. Could not open new database 'D:GCAPAPP_DATAGRIET_IT.MDF'. CREATE DATABASE is aborted.An attempt to attach an auto-named database for file D:GCAPApp_DataGRIET_IT.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +171 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2406 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +34 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +223 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +371 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +184 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +193 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +501 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +429 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +70 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +510 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +85 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +89 System.Data.SqlClient.SqlConnection.Open() +159 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +118 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +82 System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1653 System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +82 System.Web.UI.WebControls.ListControl.PerformSelect() +18 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +68 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +61 System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +26 System.Web.UI.Control.PreRenderRecursiveInternal() +88 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5684
Version Information: Microsoft .NET Framework Version:2.0.50727.832;
ASP.NET Version:2.0.50727.832
View 1 Replies
View Related
Oct 14, 2004
Hi There !!
CAn you please help me to solve my probelm and i will appreciate it if you help me. I installed SQL server on my machine and i installed tables in a database called "otters" when i run the application, i got an error message on the browser as shown below although in the application it says that it recognise the source of the dastabase. CAn you please help me to sort out tis problem and please try to look back to this thread after givingf me the soultion as it might not work and i need more assistant. I really, appreciate your help and thank you in advance. Please read the error message below
**************************************************
Server Error in '/Otters' Application.
--------------------------------------------------------------------------------
SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.
Source Error:
Line 403: Dim conn As New SqlConnection(connStr)
Line 404: cmd.Connection = conn
Line 405: conn.Open()
Line 406:
Line 407: ' Allocate an empty array list to hold the performance objects found
Source File: C:CSE506TheaterPerformance.vb Line: 405
Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
Theater.Performance.Find(SqlCommand cmd) in C:CSE506TheaterPerformance.vb:405
Theater.Performance.FindByDateRange(DateTime st, DateTime et) in C:CSE506TheaterPerformance.vb:369
Otters.admin.Page_Load(Object sender, EventArgs e) in C:InetpubwwwrootOtterssecureadmin.aspx.vb:67
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
--------------------------------------------------------------------------------
View 7 Replies
View Related
Oct 15, 2004
I'm developing a VB app to manipulate data in a table. I've created an SQL server (local) and have successfully connected to and manipulated data in a database that I created. I would like to be able to run the app on another machine and connect to the same server. I'm having trouble determining what the server name is. Tried a few things but get the "server does not exist" message. Server is set to authenticate SQL server and windows.
Is this happening because my server is (local)? If so how do I change it to permit remote access?
Any assistance would be appreciated.
View 2 Replies
View Related
Jul 20, 2005
hey!Im looking for a db tutoral which covers accessing a Microsoft SQL databaseon windows. I will be using VC++ if it matters. NO details just a basicintroduction!Oracle DB access using C++ is also of interest!Thanks!-- Majk
View 1 Replies
View Related
Jan 23, 2008
I have a MSSQL database from a pre-existing app. The data files do not have an MDF exension, they have a .dat extension. I can however use Microsoft SQL Server Management Studio Express to run queries against the files, but I can not get VB 2005 to connect. When I attemp to add it as a project data source, I get the following error:
"An attempt to attach an auto-named database for file c:dataMSSQL$DATA_SQL....dat* failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
*Database names = company names are omitted to 'protect the innocent'.
Does anyone have any ideas? Since Microsoft SQL Server Management Studio Express worked so cleanly with the database I was expecting to easily get to the same data using VB.
View 5 Replies
View Related
Feb 29, 2008
Hi,
I have an sql express server which contains a single database. Three users access this database using a C# application I have writen. I use Integrated Security for these three users.
The problem is that one of my users wishes to use my application from home.
What are my options in letting this user use my application from home?
Thanks for your help,
Barry.
View 1 Replies
View Related
Sep 5, 2006
Hi,
I'm a hobby C# programmer, and when at university there are a few machines that have SQL Server 2005 installed on them (i think it's standard ed).
From looking around at sql 2005 free edition and DNN (dot net nuke) it's apparently possible to have the database file in the execution directory of your application.
My question is this, if i have a C# win app, is in possible for me to store the database files, in the executable directory of that app, and not in the default sql database store of C:prog filessql server90 data etc...?
Ie, what i want to do, is for the C# win application on start up to "mount" the database, use it normally like any other sql database, and then "unmount" it at the end.
The reason for "mounting" and "unmounting" is that i don't want the database to be accessible or even visible to sql server when the c# app isnt running.
I hope I've explained myself clearly, and thanks a lot in advance.
pro-logic
View 3 Replies
View Related
Aug 10, 2006
Let's assume we have 2 databases db1 & db2
and we have a table named "MyTable" which is located in db2 database
in the db1 database I create a stored procedure by using following code:
<<
use db1
create procedure myproc
as begin
select * from db2.dbo.MyTable
end;
>>
this code does not execute successfuly and I face an error which says << invalid object db2.dbo.MyTable>>
and as you know we are not allowed to use USE database key word in stored procedures
I can's access a table which is located in another database, whithin a stored procedure which is located in different data base but on the same server
thanks
View 3 Replies
View Related
Nov 3, 2006
After I uploaded my web page and my sql database to my server I get the following error: Exception Details: System.Data.SqlClient.SqlException:
Could not open new database
'dsyfa.dnh.sk_0254bfa0-5525-4634-bee7-1b99fd021b34'. CREATE
DATABASE is aborted.Could not attach file
'I:DataWebdnh.skdsyfa_78676f0b-4b12-4502-8792-5141335ef179wwwApp_DataGamesDB.mdf'
as database 'dsyfa_0254bfa0-5525-4634-bee7-1b99fd021b34'.File
activation failure. The physical file name "F:My StuffSoftware
DevelopmentC#ATLASProjectsGameSiteApp_DataGamesDB_log.LDF" may be
incorrect.The log cannot be rebuilt when the primary file is read-only.Why is it referring to F:My StuffSoftware
DevelopmentC#ATLASProjectsGameSiteApp_DataGamesDB_log.LDF?? This location exists in my PC. How do I change it? I uploaded my mdf file using FileZilla FTP client. Where am I going wrong?? I'm using the connection string given me to me by the hosting service. Here's the code:<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|GamesDB.mdf;Integrated Security=True;User Instance=True" SelectCommand="SELECT [GameId], [GameTitle], [Rating], [Genre], [Location] FROM [Games]"></asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="GameId" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="GameId" HeaderText="GameId" InsertVisible="False" ReadOnly="True" SortExpression="GameId" /> <asp:BoundField DataField="GameTitle" HeaderText="GameTitle" SortExpression="GameTitle" /> <asp:BoundField DataField="Rating" HeaderText="Rating" SortExpression="Rating" /> <asp:BoundField DataField="Genre" HeaderText="Genre" SortExpression="Genre" /> <asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" /> </Columns> </asp:GridView> Any help would be appreciated.
View 3 Replies
View Related
Aug 10, 2007
I'm writing an web app in VS2005.
I've created a product.mdf database through VS2005's Server Explorer (to my knowledge, I'm not using Sql Express). (Side question. The .mdf files are a stand alone xml structure used as a database, correct?).
When I execute locally, everything works great. But when I moved my code to where it is being hosted (remote computer). It's throwing the following error:
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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
This is my connection string:<add name="MyConnectionString1" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Product.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
What is my problem?
View 3 Replies
View Related
Dec 31, 2007
I was wondering if you guys know of a good site that talks about programmatically accessing and displaying data from a sql server 05 database in ASP.NET 2.0.I want to have a data adapter in a dataset, but I would like to create my own class file and pull the data from the adapter through code into the class. Is this the best way? Im wondering about the best practices while learning this new technology. Any articles provided would be appreciated. Thanks!
View 2 Replies
View Related
Mar 19, 2008
I have written 5 content-management systems and am getting a little bored writing a lot of the same functionality and tweaking it for different datamodels. Is there a way within .NET to have visibility of a database's structure (ie, data type, column names, foreign keys etc)? I'd like to write up a dynamically generated form for any given table, displaying appropriate form controls based on data type and foreign keys.
View 7 Replies
View Related
Apr 24, 2008
I've downloaded a copy of Microsoft SQL Server Management Studio Express from MS. Can this product be used to query an SQL database at a web site.
Conversely, is there a command line utility for running SELECT statement queries on my remote web site database?
View 1 Replies
View Related
Jun 27, 2002
Hi. I have a database online. I have to run some scripts, and check out my database. The ISP i have, has currently changed the IP address for the database, now I can not hook up with it via Enterprise Manager. Can someone help me. I am using Microsoft ME as the platform.
View 1 Replies
View Related
Aug 5, 2004
Hi,
I need a way to automatically generate a daily report of user names, time of access, and type of access (login, select, insert, update, delete, etc.) to a database.
We need to audit all accesses from all accounts to find out who is accessing the payroll system. We have already defined the security to be as tight as possible - however we need to monitor all Administrator accounts to ensure they are not being used to obtain sensitive information.
I have looked for some software to read the live SQL Transaction Logs, but none of the tools I have seen can do exactly what we require. For example, I've tried Lumigent Log Explorer (http://www.lumigent.com/products/le_sql.html), but it's not automated and the report output is just garble to our payroll staff.
I have looked up all Microsoft SQL Server partners but their software is all about data recovery and data reporting. We need Security Reporting.
I have created a general SQL Profiler trace that may suffice if everything else fails, but I still have no way of automating it - it relies on Real-Time monitoring which I can't trust (admin can turn this off, do their stuff, turn it back on). Also this is dependant on someone turning it off, save the log, turn it back on, every day - this person would be the Administrator - what admin would monitor themselves?
- SQL Trace seems like a good idea, how do I read the trace log file? How do I automate a trace?
- Can we automate the SQL Profiler to read the transaction log to find all accesses to a database?
- Does anyone know what we can do to automatically audit accesses to a database? What format can the report come in (pdf, xls, dbf, html etc.)
- Recommended software to try?
- Ideas for alternatives to try?
- Any companies/developers out there who know of a tool or are developing a tool to provide this sort of report?
- Is there a spec somewhere to let us write our own software to query the live transaction log?
Thanks, I appreciate any help.
Kind Regards
James Payne
IT Administrator
View 7 Replies
View Related
Jul 25, 2007
hi guys. can you please provide tutorial/link how to access two database in one view. i was thinking about LINK TABLE like what i do in ms access but i find solution in sql server.
thnx.
View 3 Replies
View Related
Aug 10, 2006
hi
i have stored procedure and i need to access another database in my stored procedure
I'm going to query a table which is located in another database
as you know it is impossible to use the USE database keyword in stored procedures
so what should I do?
thanks.
View 2 Replies
View Related
Aug 22, 2007
hi,
do i need to use specially synchronized code if i have multiple threads inserting, updating and reading rows to and from the same database?? in this case, i know that no 2 threads will try to insert or update the exact same row into the DB, however, multiple threads might try to read the same row from the database.
thanks!
View 3 Replies
View Related
Dec 1, 2006
Apologies if this question has been asked before. I am about to upgrade a multiuser application based on Access97 and VB6 to C# and possibly SQL Server Express.
My customer does not want to use a server based database solution ie a single instance of SQL Server, but prefers to have a common networked dataset which is accessed via user's own individual database engines. This is because of restrictions on the installation of server based apps.
Does this scenario completely rule out the use of SQL Server Express?
Thanks
View 3 Replies
View Related
Feb 28, 2007
I am developing a mobile 5.0 application. I use mobile Sql as the database in the pda.
In the program, i use dataset.xsd to create the table and tableAdapter, but the performance is very slow for just access the data from the database. It takes about 4200ms for just
this.userAdapter = new PDA_USERTableAdapter();
MBDB2DataSet.PDA_USERDataTable ut = userAdapter.GetUser();
the "new PDA_USERTableAdapter()" is very fast.But...
The userAdapter.GetUser() will only return about 20 rows, each rows only contains 5 field .But it cost 4200 ms for this line.
The sql statement in userAdapter.GetUser() is
SELECT User, PASSWORD, TYPE, USER_ID, Supervisor_ID
FROM PDA_USER
WHERE (TYPE = 5)
ORDER BY User
Please Help, Urgent!!!!!
p.s (The total rows in the PDA_USER table is only 30 rows)
Thank you very much
View 3 Replies
View Related
May 7, 2008
I am writing a Sql Function in CLR. That function receives some data for processing. For processing the data, the function requires some additonal data to be fetched from the same database.
So, how does a CLR function execute SELECT or other Sql statements (or does it need to open up a SqlConnection for the purpose)???
View 1 Replies
View Related
May 9, 2007
I have a need to refresh a report after applying a filter on the data that is displayed, without accessing the database.
The following example is a simplified version of the functionality I'm trying to accomplish. The first report displays Sales & Projection data for all products. On clicking a particular product in the header, the second report displays just that product and the total metrics. I have created an rdl file for both the reports and based on the parameters passed, it displays one or several products. My concern is that the report is having to access the AS cube every time a product is clicked. In the real report, it's taking minutes to get the data. Is there way I can get the report to refresh to apply the filter without accessing the database again? Thanks in advance...
Report-1
Product
A
B
C
Total
Sales
100
200
300
600
Projection
200
200
300
700
Total
300
400
600
1300
Report-2
A
Total
Sales
100
600
Projection
200
700
Total
300
1300
View 3 Replies
View Related
Feb 14, 2008
Hi all,
In the VB 2005 Express, I can get the SqlConnection and ConnectionString of a Database "shcDB" in the Object Explorer of SQL Server Management Studio Express (SSMSE) by the following set of code:
///--CallshcSpAdoNetVB2005.vb--////
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Public Class Form1
Public Sub InsertNewFriend()
Dim connectionString As String = "Data Source=.SQLEXPRESS;Initial Catalog=shcDB;Integrated Security=SSPI;"
Dim connection As SqlConnection = New SqlConnection(connectionString)
Try
connection.Open()
Dim command As SqlCommand = New SqlCommand("sp_insertNewRecord", connection)
command.CommandType = CommandType.StoredProcedure
.......................................
etc.
///////////////////////////////////////////////////////
If the Database "shcDB" and the Stored Procedure "sp_inertNewRecord" are in the Database Explorer of VB 2005 Express, I plan to use "Data Source=local" in the following code statements to get the SqlConnection and ConnectionString:
.........................
........................
Dim connectionString As String = "Data Source=local;Initial Catalog=shcDB;Integrated Security=SSPI;"
Dim connection As SqlConnection = New SqlConnection(connectionString)
Try
connection.Open()
Dim command As SqlCommand = New SqlCommand("sp_insertNewRecord", connection)
command.CommandType = CommandType.StoredProcedure
........................
etc.
Is the "Data Source=local" statement right for this case? If not, what is the right code statement for my case?
Please help and advise.
Thanks,
Scott Chang
View 6 Replies
View Related
Jul 29, 2006
I created an SQL database in Visual Studio 2005 Express Edition and would like to edit it in SQL Server Management Studio Express. The only databases listed in the Object Explorer of SQL Server MSE are the system databases (ones that are part of the SQL Server MSE).
If I dig through the directories, I can locate my database under the Visual Studio directory, but I am unable to open it. I get an error message stating, "There is no editor available for [my database]... Make sure the application for the file type (.mdf) is installed."
I'm sure that this is a ridiculously simple rookie mistake that I'm committing somehow, but I'm stumped. Any idea what I'm doing wrong?
View 3 Replies
View Related
May 12, 2008
I just added a .asmx webservice to my project.
When i try to retrieve some information of the database using the webservice, despite using the same code as in a code behind .aspx file, it doesn't work.SqlConnection conn =
new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);DataTable dt = new DataTable();
conn.Open();
String sql = "SELECT * FROM aspnet_Users";
//But i would suggest you to use parameterize queries or SP for security reasonsSqlCommand cmd = new SqlCommand(sql, conn);cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
conn.Close();
Using this code in .aspx.cs it works, but in my .asmx it doesn't. The 'cmd.ExecuteNonQuery()' returns '-1' in the .asmx.
I have to use the webservice because i have a Silverlight client in my application, whichs has to retrieve data from the database.
Any ideas why it works for the .aspx.cs and not for the .asmx file?
View 4 Replies
View Related