I am new to thsi and I have installed the SQL server 2005 Dev (not express). I am useing Visual Web Express - When I create an application and attempt to launch it - the web config tell me that I am unable to connect to the Database - in the properties page (sidebar) the database status says closed - an I cannot seem to connect if though I go into the connections and test it says connected!
Hi I am new at this. I have a little program written in C# in asp.net. The program basically accesses a database and stores new records. The database is supposedly already attached to MSDE so I am able to see the tables of the database inside asp.net. I can click on the individual slots of the table and modify the datas manually. However, I want to connect to the database from my C# program and be able to input data into the database via the website that the C# program produces. After I type in the data into the website and click the submit button on the website, I get an error page that says this: Login failed for user 'sa' the line of code thats causing this error is: con = new SqlConnection("data source=(local)\NetSdk; initial catalog=Friends; user id=sa"); Why is it not able to connect to the database?
I am doing one of the Microsoft virtual labs "Creating ASP.NET Web Applications with C# - Part 2" using Visual Web Developer Express. I am trying to fill a gridview with database information, but it gives me the 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)".This is on the local machine that I am executing the code. public void BindGrid(string sortfield) { //Create DataAdapter to fetch data from Prodcuts table SqlDataAdapter myCommand = new SqlDataAdapter("select * from Products", myConnection); //Create dataset and fill it with Product data DataSet ds = new DataSet(); myCommand.Fill(ds, "Products"); //Bind Product data to Datagrid DataView Source = ds.Tables["Products"].DefaultView; Source.Sort = sortfield; dgProducts.DataSource = Source; dgProducts.DataBind(); } It stops on the line "myCommand.Fill(ds, "Products"); and points out the error mentioned earlier. I am not sure what to do...any help would be greatly appreciated, thanks in advance, and I apologize as well if I have not pointed out enough information.
I am having difficulty connecting to a SQL DB in my ASP page. Each time I run my application I receive the following error, "Login failed for user 'CX259ASPNET'". This is obviously something to do with permissions. I am all out of ideas but I will list the things I have already attempted to see if I either missed something or somebody can add to what I have already done.
1. In SQL Server I right-clicked the db -> properties -> security tab -> selected the option button to "SQL Server and Windows" instead of "Windows Only". 2. I installed SP3 and changed the sa password. 3. I created a new user under my db using the ASPNET account listed. I then changed the permissions to allow selecting, update, insert and delete access. 4. I also created a new user under my db using the IUSR account listed. I changed the permissions to the same settings as above.
I did a search on google which provided with all of the information above, but I am still stuck and hoping that this is a common problem and will be easy to fix.
Below is the code which I am attempting to use.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then Dim strConnString As String = _ "Data Source=(local);" & _ "Initial Catalog=Names;" & _ "Integrated Security=SSPI;" Dim objConn As New SqlConnection(strConnString) Dim strSQL As String = "SELECT * FROM [Names]" Dim objCmd As New SqlCommand(strSQL, objConn)
objConn.Open() MyDataGrid.DataSource = objCmd.ExecuteReader MyDataGrid.DataBind() objConn.Close() End If End Sub
ok, we have a development server in our office and it has SQL running on it. If i remote over to that machine i can open the database administrator and create tables and things just fine. I use the windows login.
now when i try to goto my machine and open up visual studio or dreamweaver to try to make a dataset connection it will not connect to the server. I get a message in visual studio saying it is probly because the default settings prohibit remote connections to the DB. I'm also doing the wondows login mode from the remote computer.
So is there a way i can change it so i can have remote access? i dont see how else they expect anyone to be able to do any development from a remote machine elsewise...
I'm trying to use the bcp utility to create a format file to import data from a flat file. However, bcp cannot connect to the local instance of SQLEXPRESS. I am able to connect using both Visual Studio 2005 and SSMSE. Here is what I get:
snip
C:>bcp SQLEXPRESS.SAMS1DB2.Organization_01A format nul -c -f Organization_01A.fmt -T
SQLState = 08001, NativeError = 10061
Error = [Microsoft][SQL Native Client]TCP Provider: No connection could be made because the target machine actively refused it.
Error = [Microsoft][SQL Native Client]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.
snip
SAMS1DB2 is the database name. Organization_01A is the table name.
I'm new to SQL Server but it appears to be set up to allow remote connections, using Windows Authentication, TCP/IP and Named Pipes are enabled. I have also tried to connect using sqlcmd -S and I get a similar msg.
Hello, I'm using Visual Studio 2003 and I need to be able to connect to an SQL Server 2005 Express database on the same machine using ASP.NET pages, but I'm having difficulty getting the pages to make a connection. I'm new to ASP.NET and I'm probably making some totally elemental mistake. I'd appreciate any assistance anyone can offer. I have pasted in part of the codebehind file for a web form (asterisking out the database name) and the error report that appears in the browser when I call the page.using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace WebApplication2{ /// <summary> /// Summary description for WebForm1. /// </summary> public class WebForm1 : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here string strConnection="Integrated Security=SSPI;Persist Security Info=False;"; strConnection +="initial catalog = ******;server=WILL-000993DB49\SQLEXPRESS;"; SqlConnection objConnection = new SqlConnection(strConnection); objConnection.Open(); objConnection.Close(); } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion }} Server Error in '/WebApplication2' Application.
Cannot open database "******" requested by the login. The login failed.Login failed for user 'WILL-000993DB49ASPNET'.
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: Cannot open database "******" requested by the login. The login failed.Login failed for user 'WILL-000993DB49ASPNET'.
Source Error:
Line 24: strConnection +="initial catalog = ******;server=WILL-000993DB49\SQLEXPRESS;";Line 25: SqlConnection objConnection = new SqlConnection(strConnection);Line 26: objConnection.Open();Line 27: objConnection.Close();Line 28:
Hi, I have SBS 2003 installed and have currently been working with Sharepoint. I upgraded to SQL Server 2005 using the methods described in the documentation provided on the SBS CD, which can be found here: http://go.microsoft.com/fwlink/?LinkId=60500
I followed the document step by step and the installation completed without any problems, however after installation when trying to access a website I created in Sharepoint prior to upgrading I ran into this error: "Unable to connect to database." That error led me to the following Microsoft support article: http://support.microsoft.com/kb/823287
I followed all three methods in that article to ensure that the server is running and that it is configured properly, but it didn't change a thing.
Looking in eventvwr I noticed the following:
Failure Audit: Login failed for user 'NT AUTHORITYNETWORK SERVICE'.
Followed by:
Error: #50070: Unable to connect to database
It sounds as if Network Service doens't have the appropriate permissions to access the SQL server, but I defined those permissions in the SQL Server 2005 upgrade following what the upgrade manual provided on the CD told me.
I have been fooling around with this issue for a long time now, does anyone have any ideas?
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.
This is my first post ever so forgive me if this is too basic a question.
I have an Access 2000 database that I'm trying to make into a SQL 2005 Express database. Both databases are on the same machine (I've given up with the networking of this) and, after straightening out several problems I've ran into one I can't seem to fix.
Using the Upsizing Wizard in Access 2000 I try to connect to SQL 2005 Express but I keep getting this error: http://www.paulmauer.com/SQL%20connection%20error.doc
SInce both programs are on the same machine I don't understand what is happening. Any help would be appreciated.
Hi, i am trying to get to my hosting companies database server. Its SQL Sever 2000, but i want to connect through SQL Server Management Studio 2005. The connection is unable to be established, although i have tried all sorts of settings for the connection. I called the hosting company and they told me to connect using the IP address of the name server for my domain. It failed and i called again to check back, and one of the guy told me that u cannot connect to an instance of sql servr 2000 from sql server 2005. Is this true? Please help.
Here is the information that I have... ( ps all information is not the actuall information )
1) URL abc.somehostingcompany.com IP: 211.11.111.1 PORT: 1433 ( NOTE: if I go to a cmd promt and type in ping abc.somehostingcompany.com I get a response )
2) dbname = mydatabase
3) userUid = sa pwd = sa
Inside SQL Server Configuration Manager --> SQL Server Network Configuration --> Protocols for SQLEXPRESS, I enabled TCP/IP and Shared Memory. Inside the properties of TCP / IP, I made sure under the "IP Address" tab that the
IP1: Active = yes
IP1: Enabled = yes
IP1: IP Address = abc.somehostingcompany.com
IP1: TCP Dynamic Ports = 0
IP1: TCP Port = < empty string >
I clicked "OK", and I stopped and started the SQL Server 2005 Services --> SQL Server (SQLEXPRESS). Then I started up SQL Server Brower.
Lastly I go to SQL Server Management Studio Express and try to connect to this remote server and database and I keep getting timeout issues and a message saying that the default settings for SQL Server Express do not allow remote connectioning by default.
Any ideas what I could be doing wrong? Should I use the port number instead of Dynamic Ports? Should I use the real IP address? Does the LOG ON AS under SQL Server (SQLEXPRESS) properties need to be updated?
I used VWD 2005 Express to create my web application (that uses a sql 2005 database), and now I'm trying to deploy it. I was to understand that all I had to do was to upload all my files to the root folder and the web host's server (webhost4life.com). However, they require me to upload the sql 2005 db to a seperate sql server using a control panel that is very clunky. Does anyone know how to upload the sql 2005 db to the host server or an online tutorial where I could go to learn? Thanks for the help!
Hi all, this has been bothering me for a few days now so i thought id better get some good advice! I am going through the process of exporting a SQL Server 2005 DB to my hosting company for the first time. Initially I tried using SQL Server Management Studio to "Export" the DB, which has all of the membership functionality (by runnung aspnet_regsql.exe) and a few extra tables - nothing too complicated. Exporting with SQL SMS did not seem to copy my stored procedures accross and this gave me problems. I then tried SQL Server Database Publishing Wizard - as recommended by this post: http://weblogs.asp.net/scottgu/archive/2007/01/11/tip-trick-how-to-upload-a-sql-file-to-a-hoster-and-execute-it-to-deploy-a-sql-database.aspx So this is my process: 1. set up empty DB on hosting server2. get admin to allow dbo permissions on this DB3. open SQL SDPW and create a script which will create an exact copy of my local DB4. run the script on my new empty Db on server... when i do this i get the following errors: Msg 208, Level 16, State 1, Procedure vw_aspnet_Users, Line 3Invalid object name 'dbo.aspnet_Users'.Msg 208, Level 16, State 1, Procedure vw_aspnet_MembershipUsers, Line 3Invalid object name 'dbo.aspnet_Membership'.Msg 208, Level 16, State 1, Procedure vw_aspnet_Profiles, Line 3Invalid object name 'dbo.aspnet_Profile'.Msg 208, Level 16, State 1, Procedure vw_aspnet_UsersInRoles, Line 3Invalid object name 'dbo.aspnet_UsersInRoles'.Msg 208, Level 16, State 1, Procedure vw_aspnet_WebPartState_User, Line 3Invalid object name 'dbo.aspnet_PersonalizationPerUser'.
When i look at the DB hosted on the server, it seems that all of my stored procedures are there. One thing I noticed was that some of my "Views" were in the "Tables" folder (i dont know if this matters)The result that this is having is that I do not get any errors, but the queries on my page where i reference one of my views (like vw_aspnet_MembershipUsers), the latest records are not appearing.I think that somehow my stored procedures are not referencing the correct views and tables maybe?Anyway - if anyone has come across this, please help me out (even if its just to say ive done something stupid )
I am trying to write to a database through C++ with the ODBC stuff. I can connect to and close the database as well as write certain things to it. I am having trouble writing strings or chars to it though. I'm not really a DB programmer and probably won't have to do it in C++ for a long time, so I'm just looking for some quick help so I can move on to other stuff. I know this code probably won't look right either since I;ve only seen this stuff for about 2 days now. Basically I have a string that I want to bind using SQLBindParameter so that I can use it in an ExecDirect statement. Basically when I run the little code snippet below, it writes some crazy character set out. Any help would be appreciated because I really have no clue what I'm doing.
I've created an sql database in VB express, created some tables, and entered some data in those tables. My problem now lies with actually using that data. What i'd like to do is have a Sub use the database's data and fill in a series of variables. Right now i have the Sub using an Excel file to assign the information, looks like this:
Public Sub CharStatDefault() 'loads each character's default stats
CharSheet = xlBook.Worksheets(2)
P.initialize()
For excelInt = 1 To 22
P.C(excelInt).Initialize()
With P.C(excelInt)
.Vit = CharSheet.Range("AC" & excelInt).Value
.Phy = CharSheet.Range("AD" & excelInt).Value
.Mag = CharSheet.Range("AE" & excelInt).Value
.Off = CharSheet.Range("AF" & excelInt).Value
.Def = CharSheet.Range("AG" & excelInt).Value
.Agl = CharSheet.Range("AH" & excelInt).Value
End Sub
So basically i want to change the CharSheet.Range("XX" & excelInt).Value to something that utilizes the data from my database.
tried to add a third and fourth table to an exsiting relationship diagram in VS05 server explorer, when i click save i get an error "the operation could not be completed" i am able to create new diagrams but it seems every time i click save, and close the diagram the reopen it and add new tables then click save i get the same error message, i dont even try and create the actual relationship but just add a third table and boom the problem occurs thanks in advance
I would like to know how to (if it is at all possible) in SQL (or even ADO) to retrieve all the data concerning database X's
a) Tables b) Tables column names c) Tables column's data types
I don't want to use the doa.tabledefs object.. .i would prefer to do it in SQL, but using ADO objects (since I am developing stuff in VB) would be ok too.
Please Help.. i have been going crazy trying to find anything useful.. email me back please!
Hello everyone. Pretty new to SQL Server and i've run into some trouble with something I am attempting to do.
Basically, we imported one of our databases on one of our SQL Servers to a new sql server that we just setup. That went ok with no problems. The DB is now in the new SQL Server.
Now, we need to copy the contents of a second DB from the original server into this new sql server DB. For reference:
We imported a DB Called: siebeldb We want to import/overwrite another DB into that same DB. We backedup the DB and moved the file to the new SQL server.
So:
Import/Restore: sbprd01(a backup file) into siebeldb
I hope that makes sense.
I have the following command that I am trying to execute in the SQL Query analyzer:
RESTORE DATABASE siebeldb FROM DISK='C:Documents and SettingsAdministratorDesktopsiebelprddb092509.bak' WITH MOVE 'siebelprddb_Data' TO 'C:Program FilesMicrosoft SQL ServerMSSQLDatasiebeldb_Data.mdf', MOVE 'siebelprddb_Log' TO 'C:Program FilesMicrosoft SQL ServerMSSQLDatasiebeldb_Log.mdf', REPLACE
It is running right now, but seems to be running into errors. I just added the 'REPLACE' option according to the t-sql reference guide.
Does my script look ok? Am I doing anything wrong?
Hi, I need to take a value from a textbox and insert it into a field in my database which takes decimals. My problem, no matter what I try I cannot convert the value so that the database will accept it. This all happens when the submit button is hit on my webpage. Here is the cmdSubmit_click sub code:
Dim surveyNum As Decimal = Decimal.Parse(txtSurveyNum.Text, Globalization.NumberStyles.Number) myCmd.CommandText = "INSERT INTO survey(ID) VALUES('" & surveyNum & "')" myCmd.Parameters.Add("surveyNum", SqlDbType.Decimal) myCmd.Parameters("surveyNum").Value = System.Convert.ToDecimal(txtSurveyNum.Text)
Ok, I need to give some details. I have a secure Access Database using WorkGroup Security logon. It is an Access 97 database (yes I know it is "old").
I tried to create a DTS package in SQL Server 2000 to connect to it, but I am getting the same error that I got before I "joined" the workgroup when attempting to access the DB. So I changed the Service logon identites to mimic <me> as the logon, and still I can't get it to connect. The user name and password I put in the connection are correct.
It seems like nothing is working and I am all out of ideas. Does anyone have any recommendations? Has anyone done anything like this successfully?
PS: I can manually logon to the database, and extract the data 1 table at a time, but I don't want to export 40 tables each time I have to load this data. Any help would be appreciated. Thanks in advance.
I am having trouble updating my database. I have seen a couple of other people had the same problem. Two answers I had found and tried did not work. The updating if newer I had already came across in a step by step class room tutorial written by a college professor and to make sure the save procedure came after the update procedure. I did need to make this last change but its still not updating. Any further advice on this subject would be appreciated. .
when I hit F12 to preview my page and forms etc it goes to this error
This error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying. For more information about HTTP errors, see Help.
AND when I try to hold up to an SQL database it wont let me and says the server doesnt exist still. Whats wrong with my SQL server and what can I do to resolve this problem?
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?
I am using ADOX to create linked tables in a jet database from an ODBC datasource. The tables in the ODBC data source does not have a primary key. so I am only able to create read only linked tables.But I want to update the records also. I tried adding a primary key column to the linked table while creating the link. but I am getting an error while adding the table to the catalog.
The error message is "Invalid Argument".
I use the following code for creating the linked table
Sub CreateLinkedTable(ByVal strTargetDB As String, ByVal strProviderString As String, ByVal strSourceTbl As String, ByVal strLinkTblName As String)
Dim catDB As ADOX.Catalog Dim tblLink As ADOX._Table
' Name the new Table and set its ParentCatalog property ' to the open Catalog to allow access to the Properties ' collection. .Name = strLinkTblName .ParentCatalog = catDB
' Set the properties to create the link. Dim adoxPro As ADOX.Property
Hi all,I come up with a problem aleady discussed in some posts especially in the post http://forums.asp.net/t/1235761.aspx. but I got in not finally solved.The main problem is connecting to a database twice which causes errors. So I think this might be the right place to ask my questions. Here ist the problem in short:I'm using VWD on XP-Professional with SQL-Server Express and Reporting Services Express. All with Windwos Integrated Security and User Instance (SQLExpress). In my web-application I had for all Datasources the connect string:Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|mydatabase.mdf;Integrated Security=True;User Instance=True This works fine so far. I also have Reports designed with the Report designer using the same connection string. I can preview the reports and I deployd thre reports successfully. I want to call these report using a report viewer web control.Now the problem:when I call the remote remote report from my web-application, the database cannot be opened because an other process is using the database (see post mentioned above). It seems that this is a problem with attaching the database twice: from the sql-server and from the report-server.So I used now a new connection string without "attaching" the database (in vwd and in report designer):Data Source=.SQLExpress;Initial Catalog=C:inetpubwwwrootmyappAPP_DATAmydatabase;Integrated Security=True Now everything works...but ... only on my machine. On the production machine this does not work. I wonder anyway, why its working on my machine, because I never "attach" the database (there is no connection string with AttachDbFilename and I have not opend the developer and have not opened the sql management studio).On the production machine the concurrent (SQL-Server and Report-Server) connection to database does not work with either connection strings, no matter if i attach the database with sql server manager or not).This all drives me crazy for days now. All I want is to use SQL-server and Reporting- Services with its nice features and not repairing my tools. I thought I have a standard Installation, nothing special, but the standard obviously makes problems.Here finally my question:Does this environment ( web-application with remote reports) with Express edition cause normally no problems?Can I "attach" a database only once? How should I connect with my web application that uses the sql-server connections and also the report-server-connections (attaching twice does not work).What connection strings to use and when (AttachDbFilename or Initial Catalog).Are these problems specific to the Express Editions? I thank you in advance for any help Dieter
I am very new to web development using Microsoft Visual Studio. (my primary expertise is Framemaker 2003). I am currently going through your ASP.NET 2.0 videos and reproducing the lesson content on my development system. I have Microsoft Visual Studio 2005 Professional Edition. I also have Microsoft SQL Server 2005, Microsoft SQL Server 2000, Microsoft .NET Framework SDK v1.1 and Microsoft .NET Framework SDK v2.0. I seem to be having difficulties with the SQL interface because when I try to use the Property object from Lesson04, I get System.Web.HttpExceptioon {"Unable to connect to SQL Server database."}. When I subsequently tried to Add New Item - SQL Database from Lesson08, I get a Microsoft Visual Studio error box "Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: http://go.microsoft.com/fwlink/?LinkId=49251" Any ideas? I know the videos are based on use of the Microsoft Visual Studio Express -- are there significant configuration differences between it and Microsoft Visual Studio Professional that would make these lessons incompatible?
Using web dev and sql 2005 express I have published web app and database to my server but can,t get connection string to connect with the database. --------------------------------------------------------------------- Login failed for user ''. The user is not associated with a trusted SQL Server connection. 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: Login failed for user ''. The user is not associated with a trusted SQL Server connection. --------------------------------------------------------------------- I have created a user in the logins in the sql server security node and give him every permission going. I have also created a login in the security node for the database..... and given him all permissions But I still can,t get the connection string from the web app to connect to the database? Where am I going wrong
Hi all, I am new to this field. I am trying to Connect to the database using the following code. The code does not give an error but gives an empty grid view. Can somebody figure out the mistake?protected void Page_Load(object sender, EventArgs e) {if (!IsPostBack) BindGridView(); }void BindGridView() { System.Data.SqlClient.SqlConnection sqlconnect = new System.Data.SqlClient.SqlConnection("");//added connection string here String command = "SELECT * from table";System.Data.SqlClient.SqlCommand sqlcommand = new System.Data.SqlClient.SqlCommand(); sqlcommand.CommandText = command; sqlcommand.Connection = sqlconnect;System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(); da.SelectCommand = sqlcommand;DataSet ds = new DataSet(); sqlconnect.Open(); sqlcommand.ExecuteNonQuery(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); sqlconnect.Close(); }
I have a file called upload.vb and I am having a lot of trouble figuring out how to connect to a database that I have created in my App_Data folder called myDatabase.mdf. Here is the code on for upload.vb Imports System Imports System.Data Imports System.Configuration Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Imports System.IO Imports System.Data.SqlClient
Public Class Upload Implements IHttpHandler, IReadOnlySessionState
Public Sub New() End Sub
#Region "IHttpHandler Members"
Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable Get Return True End Get End Property
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
If context.Request.Files.Count > 0 Then ' get the applications path Dim tempFile As String = context.Request.PhysicalApplicationPath ' loop through all the uploaded files Dim j As Integer = 0 While j < context.Request.Files.Count ' get the current file Dim uploadFile As HttpPostedFile = context.Request.Files(j) ' if there was a file uploded If uploadFile.ContentLength > 0 Then
End If System.Math.Max(System.Threading.Interlocked.Increment(j), j - 1) End While End If ' Used as a fix for a bug in mac flash player that makes the ' onComplete event not fire HttpContext.Current.Response.Write(" ") End Sub
#End Region
End Class Everytime I attempt to create a database connection I get all kinds Compiler errors. If anybody can help me understand how to connect to my database from this page I would greatly appreciate it. Thanks.
I am new to the visual web development program; however, I have created many applications using Visual Studio Express in Visual Basic. I am trying to figure out how to:1. Define a connection string in VB2. Open a current Connection3. Define a SqlStatement4. Retrieve the information5. Display results in textboxI am basically trying to get a login system set up so that a user can type in his name and password and is then directed to a secure page.When I create a new application and want to do this I would use the following code: Dim cnUsers As New SqlClient.SqlconnectionDim cnUsersString As String = "CONNECTION STRING"Dim UserCommand As NEw SqlClient.SqlCommand = "Select chrUsers, chrPassword FROM tblUsers WHERE chrUsers = '" & txtUserName.Text & "' AND chrPassword = '" & txtPassword.Text & "'" cnUsers.ConnectionString = cbUsersStringcnUsers.Open()UserCommand.Connection = cnUserstxtResults.Text = cnUsers.ExecuteNonQuery()cnUsers.Close() That is a very rough draft of what I would code it as. If you have any suggestions please let me know! - NUStudent-
I have an SQL database setup but i don't know how to connect to it to set up a table. I have a vague idea about connectionstrings and such. I have a server name, a database name, a user id and a password. I would like to set it up so i can just enter the SQL commands and create a table and enter data. But first I need to connect to the database. I
I am moving my site from a shared environment to a dedicated server and SQL is on the same box. How do I connect to my database if it's on the same box?