What Different Are There Between ConnectionString (Part 1) And ConnectionString (Part 2) In Web.config
Apr 12, 2006
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!
--------------------------------------Part 1------------------------------------------------------------------------
<add name="MyConnect" connectionString="Data Source=.SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|ASPNETDB.MDF"
providerName="System.Data.SqlClient" />
--------------------------------------Part 1------------------------------------------------------------------------
--------------------------------------Part 2------------------------------------------------------------------------
<add name="MyConnect" connectionString="Data Source=CCWWSQLEXPRESS;Initial Catalog=ASPNETDB.MDF;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|ASPNETDB.MDF"
providerName="System.Data.SqlClient" />
--------------------------------------Part 2------------------------------------------------------------------------
View 2 Replies
ADVERTISEMENT
Apr 6, 2006
I've defined my connection string in the web.config file:
<add name="RealtorXConnectionString" connectionString="Data Source=localhostSQLExpress;Initial Catalog=RealtorX;User ID=sa;password=welcome" providerName="System.Data.SqlClient" />
Now I want to get that string and use it in some code where I'm going to run a query against the database. This query happens in PageLoad, and won't be bound to any UI component. How can I replace XXXXX below with the value stored in web.config?
Dim strConnection As String = XXXXX
Dim cn As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(strConnection)
cn.Open()
View 4 Replies
View Related
Jan 24, 2006
Hi:
I have some query that takes quite a long time to process in the sql server and every time the page seems to time out.
I wondor is there any Timeout setting that I can defined in the database ConnectionString in web.config file so that I can extend the "wait" time?
Many thanks!
View 4 Replies
View Related
Jan 4, 2008
I have an application where I need to store the connectionstring not hardcoded in Web.config but in HttpRuntimeCache.However I want to use the membership provider which is normally set up to look for the connection string in a node of web.config.Is it possible to create a membership provider that doesn't need to get a connectionstring from Web.Config? Or looking at it a different way... Is it possible to have a connectionString setting in Web.Config where the value isn't hardcoded but looked up from HttpRuntimeCache?Thanks.
View 1 Replies
View Related
Oct 29, 2007
I have SSRS 2005 SP2 configured to work in Sharepoint integration. Everything works fine except that I am not able to programmatically change any property of report viewer web part (instance) that I have added on on home page of my sharepoint site.
I can do same thing via sharepoint UI but not through program. When my programs runs it fetches all web parts been added on home page, then I need to iterate through each one and find report viewer web part.
While iterating, as soon as I arrive to report viewer web part it is named as "Error web part" with error message as
"Windows SharePoint Services cannot deserialize the Web Part. Check the format of the properties and try again"
If someone has a solution, please respond at your earlist.
Thanks
Shankar
View 1 Replies
View Related
Dec 7, 2007
I have a table with a column named measurement decimal(18,1). If the value is 2.0, I want the stored proc to return 2 but if the value is 2.5 I want the stored proc to return 2.5. So if the value after the decimal point is 0, I only want the stored proc to return the integer portion. Is there a sql function that I can use to determine what the fraction part of the decimal value is? In c#, I can use
dr["measurement "].ToString().Split(".".ToCharArray())[1] to see what the value after the decimal is.
View 3 Replies
View Related
Jan 28, 2015
I have made the following Scalar-valued function:
CREATE FUNCTION [dbo].[TimeCalc]
(
@OriginalTime AS INTEGER
, @TenthsOrHundredths AS INTEGER -- code 2: 1/10, code 4: 1/100
)
RETURNS NVARCHAR(8)
[Code] ....
What it does is convert numbers to times
E.g.: 81230 gets divided by 10 (times in seconds: 8123). This 1 1 full minute, and the remainder = 2123 making it 1.21.23 mins)
So far so good (function works perfectly)
My question: sometimes times are in 1/100 (like above sample), sometimes in 1/10.
This means that, e.g. with a time like 3.23.40 the last zero must be deleted.
My thoughts are to use the results from the Return Case part, and as the code = 4: leave it as it is,
is the code 2 the use LEFT(... result Return Case ..., Len(..result Return Case.. - 1))
There are 5 codes: 0 1 2 3 and 4
View 9 Replies
View Related
Mar 1, 2008
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
View 2 Replies
View Related
Nov 24, 2005
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
View 3 Replies
View Related
May 11, 2006
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
View 13 Replies
View Related
Mar 18, 2008
hey all,
Im a bit lost as what i should have in my connectionString to a sql server
string connectionString = "server=localhost;database=databasename; uid=sa;pw=sa";
The server is on the localhost, the database name is ok, but what do I put in for the username and password?, At the moment because it is hosted locally I am not using any logins.
Thanks
idgeit
View 6 Replies
View Related
Jun 28, 2006
I am having trouble initializing my connection. This is the code:
Dim
DBConnPhone As New
SqlConnection(ConfigurationManager.AppSettings("DBConnPhone"))
Dim DBConnClient As New
SqlConnection(ConfigurationManager.AppSettings("DBConnClient"))
Dim Sqlcomm1 As New SqlCommand
Dim Sqlcomm2 As New SqlCommand
DBConnPhone.Open()
DBConnClient.Open()
Once I start debugging, it stops and give me the error "The ConnectionString Property was not initialized" Any suggestions?
View 4 Replies
View Related
Nov 23, 2006
Hello! I am working at a ASP.NET Project with has a sign-in area. All users (the aspnet_Membership and so on) are on an external SQL Server stored.The ConnectionString in the web.config looks like this:<add name="hspWerbung" connectionString="Persist Security Info=False;User ID=XXXXX;Password=XXXXX;Initial Catalog=HSPWERBUNG01;Data Source=SERVER_SQL_02STOCKHOLM" providerName="System.Data.SqlClient" />Is there any way to create a ConnectionString without the User ID and without the password?When i want to reach my site on the web (not with http://localhost/...) , i can't do it with "Integrated Security=True", because there will be no user, or?
View 1 Replies
View Related
Dec 9, 2006
Hay, I have a problem with this connectionstring.Dim myConnection As New Data.OleDb.OleDbConnection("Provider=SQLNCLI;Data Source=whatever-ja4lbqsqlexpress;Initial Catalog=Account;Integrated Security=SSPI;")I use this code to receive a value on a specific query Public Sub readdata(ByVal myconnectionstring As String)
Dim mySelectQuery As String = "SELECT UserName, Password FROM TAccount WHERE UseName = '" & TextBox1.Text & "'; and Password = '" & TextBox2.Text & "';"
Dim mycommand As New Data.OleDb.OleDbCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myreader As Data.OleDb.OleDbDataReader
myreader = mycommand.ExecuteReader
While myreader.Read
Label1.Text = myreader.GetString(1)
End While
myreader.Close()
myConnection.Close()
End Sub But when it execute i receive this exeption Login timeout expiredAn 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.SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. Is this mean that i can not make a connection to my sql server 2005.
My sql server 2005 runs on my developer computer
View 2 Replies
View Related
Feb 14, 2007
Hi, After many nights without sleep I'm not seeing this? Can anyone help why I'm getting a ConnectionString Property not set error? thanks!
Dim Sconn As StringDim DBCon As New Data.SqlClient.SqlConnectionSconn = ConfigurationManager.AppSettings("LocalSqlServer")DBCon = New SqlClient.SqlConnection(Sconn)Dim cmdCommand As New Data.SqlClient.SqlCommand
'Dont forget to instantiate a connection object
cmdCommand.Connection = DBConDBCon.Open()
View 18 Replies
View Related
Jun 25, 2007
Hello, Well actually I am beginner to ASP.Net, I am working on Microsoft Virtual PC with VS 2005 and SQL Server 2005 installed. Now when Create web application in Studio all works fine with databases but when i try to write some code for accessing SQL Databases I keep getting this error PLZ heLP.Following is my code<% @ Import Namespace="System.Data" %><% @ Import Namespace="System.Data.SqlClient" %><html><script language="C#" runat="server" Debug="false" >SqlConnection sqlcon;protected void Page_Load(Object Src, EventArgs e){ sqlcon=new SqlConnection("Data Source=VS02005;Initial Catalog=Gaurav;Integrated Security=True"); SqlDataAdapter sqlcom = new SqlDataAdapter("select * from Employee", sqlcon); DataSet ds = new DataSet(); sqlcom.Fill(ds,"Employee"); DataGrid1.DataSource = ds.Tables["Employee"].DefaultView; DataGrid1.DataBind();}</script><form runtat="server"> <asp:datagrid id="DataGrid1" runat="server" /></form></html>This is the error i am gettingServer Error in '/' Application.--------------------------------------------------------------------------------SELECT permission denied on object 'Employee', database 'Gaurav', schema 'dbo'. 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: SELECT permission denied on object 'Employee', database 'Gaurav', schema 'dbo'. I am stuck dont know what to do, I hve checked all permissions for user gaurav, I also gave administrator rights to gaurav but nothing is working PLEASE help me.
View 4 Replies
View Related
Jul 4, 2007
This works:
SqlDataSource1.ConnectionString = "Data Source=mydb.myserver.com;Initial Catalog=mydbname;User ID=mydblogin; pwd=mydbpassword";
This doesn't:
SqlDataSource1.ConnectionString = "<%$ ConnectionStrings:myConnectionString_from_WebConfig %>"
Ok, how do I tell it to use my connection string from my web.config?
View 5 Replies
View Related
Mar 5, 2008
HiI've my ConnectionString in web.config... I want to display the DB UserID on my webPage and UserID is specified in ConnectionString... Can any one help me in this caseThanksNasir Ibrahim
View 2 Replies
View Related
Oct 26, 2004
hi,
i have problem in connectionstring in sql server.
my connection string is,
------
conn.ConnectionString = "workstation id=BARODA;packet size=4096;integrated security=SSPI;data source=BARODAMYINSTANCE;user id=sa;password=;persist security info=True;initial catalog=SMS"
it will give error like.....
login fail for user "MERIDIANIUSER_GROUP"
-------
conn.ConnectionString = "workstation id=BARODA;packet size=4096;data source=BARODAMYINSTANCE;user id=sa;password=;persist security info=True;initial catalog=SMS"
it will give error like.....
login fail for user "sa"
-------
conn.ConnectionString = "workstation id=BARODA;packet size=4096;data source=BARODAMYINSTANCE;user id=;password=;persist security info=True;initial catalog=SMS"
it will give error like.....
login fail for user "(null)"
i can do everything, but error occur everytimes.
when i use this, without instance
conn.ConnectionString = "workstation id=BARODA;packet size=4096;data source=BARODA;user id=;password=;persist security info=True;initial catalog=SMS"
it will run successfully,
but i have instance,
and i want to run with it.
plz give any idea.
it's urgent.
thanks in advance.
View 3 Replies
View Related
Mar 11, 2006
when I write this code in web.config :
<configuration>
<appsettings>
<addkey="constring" VALUE="WORKSTATION id=I-85096B7FC8F64;packet catalog='test"/' info="True;initial" security="SSPI;data" source="I-85096B7FC8F64;persist" size="4096;integrated">
<system.web>
and write this statements in the code of program :
string Constring = ConfigurationSettings.AppSettings("constring"); SqlConnection conn = new SqlConnection(constring);
this error is displyed:
The name 'constring' does not exist in the class or namespace 'C_sharp1.WebForm1'
View 2 Replies
View Related
Apr 1, 2008
hi
I have completed a windows db app.
I have saved the db files in the application/bin/ folder.
The connectionstring that i am using is
Code:
sql
Server =(local);Data Source=.SQLEXPRESS;DataBase=;Integrated Security=SSPI
say i wanted to install this app on my home computer, does not have sql express or anything installed.
Now i want to use the application and it must read/write data from the sql db that was saved in the application/bin/ folder.
what is the connectionstring then ?
can anyone please help ?
what im trying to say is that the application must work independent from any SQL manager/express etc.
is that possible ?
View 3 Replies
View Related
Apr 3, 2007
Hello All,
I have changed connection string property of connectionmanger at runtime and saved package.But my new connectionstring is not persisting, i am getting my old connection string after reload package .
ConnectionManager cm = package.Connections[test.ConnectionManagerID];
cm.ConnectionString = @"C:Test.csv";
app.SaveToDtsServer(package, null,
@"File SystemDupaco Load Next Best.dtsx", "CIRCLE");
How can I save new connection string?.
Please help me.
Thanks
Subin
View 1 Replies
View Related
Nov 22, 2006
Hi, does anyone knows where can i find all the values that support the connectionstring??? since the connectionstring uses the "server=local;database=nortwind;UID=me...."
etc. are there more parameteres to specify ?? which one of them is not REALLY important?, where can i find a list or something about it??
Thank you, i hope i made my point clear
View 10 Replies
View Related
Jul 26, 2006
<VS2005, SQL Everywhere CTP>
When I create typed datasets (for SQL Everywhere db) using the VS designer, I get a connectionString like Data Source =".App_DataDb1.sdf" added to the settings file by the designer. This works fine in the designer but not at runtime. If I replace the settings value to Data Source ="|DataDirectory|App_DataDb1.sdf" then it works fine at runtime but breaks the designer. I looked at the typed dataset designer generated code & it creates a SqlCeConnection object which supports |DataDirectory| macro. So, how can I get the designer & runtime to agree on a connectionString. I guess I can create a partial class for the table adapters & force a connectionString at runtime via a constructor overload, but, is that my only option?
Btw, the error I get at runtime when using the designer generated connectionString is:
"The path is not valid. Check the directory for the database."
View 3 Replies
View Related
Jul 25, 2006
hi,
I'm having this application using the express way to create the dategridview by having the query string builder. However, my computer recently crashed and I have no idea to change the connection string. so when I load the whole windows application, I am unable to view the information that are supposed to be in the datagridview. however, it returned an exception.
after finding out the main culprit, I realised that the database is using the old sql server's login. since it is using the old database's login, therefore it is unable to log the information into the datagrid view.
Please help! Thanks.
View 2 Replies
View Related
Jan 8, 2007
Hi all,
I want to connect to an SqlServer database and I have given the connectionstring on an WinXP computer as Dim ConnectionString As String = "server='localhost'; trusted_connection=true; Database='domains'"
Now, when I copied the files to another computer which is Win 2003 Server, I had to give the connectionstring as
Dim ConnectionString As String = "workstation id=INFO0;packet size=4096;integrated security=SSPI;data source=INFO0;persist security info=False;initial catalog=domains"
Now, I want to upload the files to a website called "BrowseNow.com".
What should be the connectionstring when the files are being uploaded to the server.
I want the public to read from and write to this database tables.
Is there anything I should do witht the SQL Server Enterprise Manager?
Thanking you in advance,
Tomy
View 2 Replies
View Related
Jul 30, 2007
In short, I have a couple grid views on a page that are used for editing as well as sorting, etc. The grids are setup to use the SqlDataSources. I'm trying to deploy this to a server environment for different instances (test,cert,prod) and am trying to set the ConnectionString for the SqlDataSource in the code behind (Page_Load()). Everything works well, except, I get an error message that says the "ConnectionString Property Has Not Been Initialized." Its a javascript alert coming up on top of the grid view.
Here is how I'm trying to set the ConnString in the Page_Load():this.EmployeeTimeCardDataSource.ConnectionString = ConfigurationManager.ConnectionStrings[connStr].ConnectionString;
Here is an example of the DataSource.<asp:SqlDataSource ID="EmployeeTimeCardDataSource" runat="server" SelectCommand="sp_Select_Managers_Employees_List" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:SessionParameter Name="CurrentUser" SessionField="User" Type="String" /> </SelectParameters></asp:SqlDataSource>
View 5 Replies
View Related
Oct 22, 2007
I am getting an error message that says that my connection string has not been intialized I have initialized it.
Dim AirliquidiConn As New SqlClient.SqlConnection(ConfigurationManager.AppSettings("AirliquidiDatabase"))
Any suggestions??
View 10 Replies
View Related
Jan 25, 2008
Hi all
This is the code in my web.config file.
<appSettings> <add key="ConnectionString" value="server=127.0.0.1;database=testdb;uid=sa;pwd=sa"/> </appSettings>
When I'm connecting to the sqlserver database,the page shows that The ConnectionString property has not been initialized.
The code that I used to get the "ConnectionString" as belows
using System.Configuration;
protected static string connectionString =ConfigurationSettings.AppSettings["ConnectionString"];
public static object GetSingle(string SQLString,params SqlParameter[] cmdParms) { using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand()) { try { PrepareCommand(cmd, connection, null,SQLString, cmdParms); object obj = cmd.ExecuteScalar(); cmd.Parameters.Clear(); if((Object.Equals(obj,null))||(Object.Equals(obj,System.DBNull.Value))) { return null; } else { return obj; } } catch(System.Data.SqlClient.SqlException e) { throw new Exception(e.Message); } } } }
These code works well on my machine.When running on my colleague's machine ,the page show that exception.
Any ideal?
View 3 Replies
View Related
Mar 20, 2008
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?
View 2 Replies
View Related
Mar 21, 2008
I tried to insert my inputs into the database but it says "The ConnectionString property has not been initialized."
These are my codes:
SubmitAssigment.aspx.vb
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conn As SqlConnection Dim mycmd As SqlCommand Dim dr As SqlDataReader Dim str As String conn = New SqlConnection(Configuration.ConfigurationManager.AppSettings("ConnectionString")) conn.Open() str = "INSERT INTO [UploadInfo] ([StudentID], [Subject], [Assigment], [File], [Upload], [Time]) VALUES (@StudentID, @Subject, @Assigment, @File, @Upload , @Time )" mycmd = New SqlCommand(str, conn) mycmd.Parameters.Add("@StudentID", Data.SqlDbType.VarChar, 500).Value = User.Identity.Name mycmd.Parameters.Add("@Subject", Data.SqlDbType.VarChar, 500).Value = DropDownList1.SelectedValue mycmd.Parameters.Add("@Assigment", Data.SqlDbType.VarChar, 500).Value = DropDownList2.SelectedValue mycmd.Parameters.Add("@File", Data.SqlDbType.VarChar, 500).Value = File1.PostedFile.FileName mycmd.Parameters.Add("@Upload", Data.SqlDbType.VarChar, 500).Value = "Yes" mycmd.Parameters.Add("@Time", Data.SqlDbType.VarChar, 500).Value = System.DateTime.Now dr = mycmd.ExecuteReader() mycmd.Dispose() dr.Close() End Sub
SubmitAssigment.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="SubmitAssigment.aspx.vb" Inherits="Student_SubmitAssigment" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <style type="text/css"> .style1 { width: 100%; } .style2 { width: 70px; } .style3 { width: 106px; } </style></head><body> <form id="Form1" method="post" enctype="multipart/form-data" runat="server"> <p> </p> <table class="style1"> <tr> <td class="style2"> Subject:</td> <td> <asp:DropDownList ID="DropDownList1" runat="server" Height="16px" Width="253px"> <asp:ListItem Selected="True">Select one....</asp:ListItem> <asp:ListItem>TCP2411 - Programming Language Concept</asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td class="style2"> Assigment</td> <td> <asp:DropDownList ID="DropDownList2" runat="server" Height="16px" Width="105px"> <asp:ListItem Selected="True">Select one....</asp:ListItem> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem></asp:ListItem> </asp:DropDownList> </td> </tr> </table><p> </p> <input type= "file" id= "File1" name= "File1" runat="server" /> <br /><br /> <asp:Button ID="Submit1" runat="server" Text="Upload" /> <br /> <br /> <br /> <asp:LoginName ID="LoginName" runat="server" /> <br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [UploadInfo] WHERE [StudentID] = @original_StudentID AND [Subject] = @original_Subject AND [Assigment] = @original_Assigment AND [File] = @original_File AND [Upload] = @original_Upload AND [Time] = @original_Time" InsertCommand="INSERT INTO [UploadInfo] ([StudentID], [Subject], [Assigment], [File], [Upload], [Time]) VALUES (@StudentID, @Subject, @Assigment, @File, @Upload , @Time))" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [StudentID], [Subject], [Assigment], [File], [Upload], [Time] FROM [UploadInfo]" UpdateCommand="UPDATE [UploadInfo] SET [Subject] = @Subject, [Assigment] = @Assigment, [File] = @File, [Upload] = @Upload, [Time] = @Time WHERE [StudentID] = @original_StudentID AND [Subject] = @original_Subject AND [Assigment] = @original_Assigment AND [File] = @original_File AND [Upload] = @original_Upload AND [Time] = @original_Time"> <DeleteParameters> <asp:Parameter Name="original_StudentID" Type="String" /> <asp:Parameter Name="original_Subject" Type="String" /> <asp:Parameter Name="original_Assigment" Type="String" /> <asp:Parameter Name="original_File" Type="Object" /> <asp:Parameter Name="original_Upload" Type="String" /> <asp:Parameter Name="original_Time" Type="DateTime" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="Subject" Type="String" /> <asp:Parameter Name="Assigment" Type="String" /> <asp:Parameter Name="File" Type="Object" /> <asp:Parameter Name="Upload" Type="String" /> <asp:Parameter Name="Time" Type="DateTime" /> <asp:Parameter Name="original_StudentID" Type="String" /> <asp:Parameter Name="original_Subject" Type="String" /> <asp:Parameter Name="original_Assigment" Type="String" /> <asp:Parameter Name="original_File" Type="Object" /> <asp:Parameter Name="original_Upload" Type="String" /> <asp:Parameter Name="original_Time" Type="DateTime" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name ="StudentID" Type="String" /> <asp:Parameter Name ="Subject" Type="String" /> <asp:Parameter Name ="Assigment" Type="String" /> <asp:Parameter Name ="File" Type="Object" /> <asp:Parameter Name ="Upload" Type="String" /> <asp:Parameter Name ="Time" Type="DateTime" /> </InsertParameters> </asp:SqlDataSource> <table class="style1"> <tr> <td class="style3"> <asp:Button ID="Button1" runat="server" Text="Confirm" Width="68px" style="height: 26px" /> </td> <td> </td> </tr> <tr> <td class="style3"> </td> <td> </td> </tr> </table> <br /></form> </body></html>
Can anyone help me out?
Pleasee
Thannkss...
View 2 Replies
View Related
Nov 18, 2005
My IT dept set up an SQL db on a server for me and I am connected to it through a port. They told me I had to create my tables through an MS Access adp, which I have done. I am using VWD Express and am trying to create a login page using usernames and pw's from a db table. I am connected (at least the db Explorer tab shows I am) to the MS Access adp and can drop a GridView from my Employees table from it onto a page and get results. I keep getting the "ConnectionString property not initialized" error message pointing to my sqlConn.Open() statement and cannot figure out why. I have looked at hundreds of posts but can't seem to find anything that works. If someone could point me to some post or website that could explain connecting to a SQL db through a port or whatever you think I need to learn to get this fixed I would appreciate it. Web config:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
<add name="ASPNETDB" connectionString="Description=Training;DRIVER=SQL Server;SERVER=USAWVAS27;UID=usx14611;APP=Microsoft® Visual Studio® 2005;WSID=983QD21;Network=DBMSSOCN;Address=USAWVAS27,3180;Trusted_Connection=Yes" providerName="System.Data.Odbc" />
</connectionStrings>
<system.web>
<authentication mode="Forms" />
<authorization>
<deny users="?" />
</authorization>
<customErrors mode="Off" />
</system.web>
</configuration>My login.aspx page
<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration.ConfigurationManager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub LoginUser(ByVal s As Object, ByVal e As EventArgs)
Dim blnAuthenticate As Boolean = Authenticate(username.Text, password.Text)
If blnAuthenticate Then
FormsAuthentication.RedirectFromLoginPage(username.Text, False)
End If
End Sub
Function Authenticate(ByVal strUsername As String, ByVal strPassword As String) As Boolean
Dim strConnection As String = ConfigurationManager.AppSettings("ASPNETDB")
Tried this code as wellDim sqlConn As New SqlConnection(ConfigurationManager.AppSettings("ASPNETDB"))
Dim sqlConn As New SqlConnection(strConnection)
Dim sqlCmd As SqlCommand
Dim sqlDR As SqlDataReader
Dim userFound As Boolean
sqlCmd = New SqlCommand("SELECT * FROM Employees " & _
"WHERE username='" & strUsername & " ' AND password='" & strPassword & "'", sqlConn)
sqlConn.Open()
sqlDR = sqlCmd.ExecuteReader()
userFound = sqlDR.Read()
sqlDR.Close()
Return userFound
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Username:<asp:TextBox ID="username" runat="server"></asp:TextBox><br />
<br />
<p>Password:<asp:TextBox ID="password" runat="server"></asp:TextBox><br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Login" OnClick="LoginUser" /> </div>
</form>
</body>
</html>Thanks
View 5 Replies
View Related